Fork me on GitHub

closure-compiler:minify

Full name:

com.github.blutorange:closure-compiler-maven-plugin:2.30.0:minify

Description:

Goal for combining and/or minifying JavaScript files with closure compiler.

Attributes:

  • Requires a Maven project to be executed.
  • The goal is not marked as thread-safe and thus does not support parallel builds.
  • Binds by default to the lifecycle phase: process-resources.

Optional Parameters

Name Type Since Description
<allowReplacingInputFiles> boolean - By default, when the output file is the same as the input file, compilation is terminated with an error. This is done to prevent source files from being overwritten accidentally with a bad configuration. If you are certain you want to replace the input files (such as when the input files themselves are temporary files that have been generated), set this option to true. Defaults to false.

Note: When enabling this option, you might also want to set skipMerge to true and the outputFilename to #{path}/#{basename}.#{extension}.


Default value is: false.
User property is: allowReplacingInputFiles.
<baseSourceDir> File - Base directory for source files. This should be an absolute path; if not, it must be relative to the project base directory. Use variables such as basedir to make it relative to the current directory.
Default value is: ${basedir}/src/main/webapp.
User property is: baseSourceDir.
<baseTargetDir> File - Base directory for output files. This should be an absolute path; if not, it must be relative to the project base directory. Use variables such as project.build.directory to make it relative to the current directory.
Default value is: ${project.build.directory}/${project.build.finalName}.
User property is: baseTargetDir.
<bufferSize> int - Size of the buffer used to read source files.
Default value is: 4096.
User property is: bufferSize.
<bundleConfiguration> String 1.7.5 Specify aggregations in an external JSON formatted config file. If not an absolute path, it must be relative to the project base directory.
User property is: bundleConfiguration.
<closureAllowDynamicImport> boolean 2.21.0 Enables experimental support for allowing dynamic import expressions import('./path') to pass through the compiler unchanged. Enabling this requires setting closureLanguageOut to at least ECMASCRIPT_2020.
Default value is: false.
User property is: closureAllowDynamicImport.
<closureAngularPass> boolean 1.7.3 Generate $inject properties for AngularJS for functions annotated with @ngInject.
Default value is: false.
User property is: closureAngularPass.
<closureAssumeFunctionWrapper> boolean 2.1 Enable additional optimizations based on the assumption that the output will be wrapped with a function wrapper. This flag is used to indicate that "global" declarations will not actually be global but instead isolated to the compilation unit. This enables additional optimizations.
Default value is: false.
User property is: closureAssumeFunctionWrapper.
<closureChunkOutputType> CompilerOptions$ChunkOutputType 2.27.0 Regardless of input type, the compiler will normalize all files and bundle them together. By default, a single output file is produced. However, this may not work for you if your application is really big. In that case, you may want to have the compiler break your code up into multiple chunks that can be loaded separately. You will design your application so that the code you always need gets loaded in an initial chunk, probably from a <script> tag, then that chunk will load others (which may load still others) as needed in order to support the user's actions. (e.g. The user may request a new display view, which requires you to load the code for showing that view.)
  • GLOBAL_NAMESPACE (Chunks as Scripts using a Global Namespace): This is the default option and the compiler will produce standard scripts. This mode is normally paired with the closureOutputWrapper flag for script isolation and the closureRenamePrefixNamespace flag so that symbols can be referenced across chunks.
  • ES_MODULES (Chunks as Ecmacript modules): The compiler will output es modules and cross chunk references will utilize the import and export statements. Since modules have built in isolation and modern browsers know how to load them, this option is by far the easiest.

Default value is: GLOBAL_NAMESPACE.
User property is: closureChunkOutputType.
<closureColorizeErrorOutput> boolean 2.0.0 Whether the error output from the closure compiler is colorized. Color codes may not be supported by all terminals.
Default value is: true.
User property is: closureColorizeErrorOutput.
<closureCompilationLevel> CompilationLevel 1.7.2 The degree of compression and optimization to apply to your JavaScript.
There are three possible compilation levels:
  • WHITESPACE_ONLY: Just removes whitespace and comments from your JavaScript.
  • SIMPLE_OPTIMIZATIONS: Performs compression and optimization that does not interfere with the interaction between the compiled JavaScript and other JavaScript. This level renames only local variables.
  • ADVANCED_OPTIMIZATIONS: Achieves the highest level of compression by renaming symbols in your JavaScript. When using ADVANCED_OPTIMIZATIONS compilation you must perform extra steps to preserve references to external symbols. See Advanced Compilation and Externs for more information about ADVANCED_OPTIMIZATIONS.
  • BUNDLE: Leaves all compiler options unchanged. For advanced usage if you want to seet the releavant options yourself.

Default value is: SIMPLE_OPTIMIZATIONS.
User property is: closureCompilationLevel.
<closureCreateSourceMap> boolean 2.1.0 Collects information mapping the generated (compiled) source back to its original source for debugging purposes.
Default value is: false.
User property is: closureCreateSourceMap.
<closureDebug> boolean 2.1.0 Enable debugging options. Property renaming uses long mangled names which can be mapped back to the original name.
Default value is: false.
User property is: closureDebug.
<closureDefineReplacements> HashMap<String,String> 1.7.5 Override the value of variables annotated with @define.
The format is:

<define>
    <name>value</name>
</define>

where <name> is the name of a @define variable and value is a JavaScript boolean, number or string literal. That is, use quotation marks to specify a string: "First line\nseconds line"
User property is: closureDefineReplacements.
<closureDependencyEntryPoints> ArrayList<String> 2.0.0

When you use closureDependencyMode PRUNE or PRUNE_LEGACY, you must specify to the compiler what the entry points of your application are. Beginning at those entry points, it will trace through the files to discover what sources are actually referenced and will drop all other files.

Adds a collection of symbols to always keep. In dependency pruning mode, we will automatically keep all the transitive dependencies of these symbols. The syntactic form of a symbol depends on the type of dependency primitives we're using. For example, goog.provide('foo.bar') provides the symbol foo.bar. Entry points can be scoped to a module by specifying mod2:foo.bar.

There are two different types of entry points, closures and modules:

  • closure: A closure namespace used as an entry point. May start with goog: when provided as a flag from the command line. Closure entry points may also be formatted as: goog:moduleName:name.space which specifies that the module name and provided namespace are different
  • file: Must start with the prefix file:. AES6 or CommonJS modules used as an entry point. The file path is relative to the sourceDir.

User property is: closureDependencyEntryPoints.
<closureDependencyMode> DependencyModeFlag 2.0.0 How compiler should prune files based on the provide-require dependency graph.
  • NONE All input files will be included in the compilation in the order they were specified in.
  • SORT_ONLY All input files will be included in the compilation in dependency order.
  • PRUNE Input files that are transitive dependencies of the entry points will be included in the compilation in dependency order. All other input files will be dropped. All entry points must be explicitly defined.
  • PRUNE_LEGACY (deprecated) Input files that are transitive dependencies of the entry points will be included in the compilation in dependency order. All other input files will be dropped. In addition to the explicitly defined entry points, moochers (files not explicitly defining a module) are implicit entry points.

Default value is: NONE.
User property is: closureDependencyMode.
<closureDynamicImportAlias> String 2.22.0 Instructs the compiler to replace dynamic import expressions with a function call using the specified name. This allows dynamic import expressions to be externally polyfilled when the output language level does not natively support them.
User property is: closureDynamicImportAlias.
<closureEmitUseStrict> boolean 2.1.0 Start output with 'use strict';.
Default value is: true.
User property is: closureEmitUseStrict.
<closureEnvironment> CompilerOptions$Environment 1.7.5 Determines the set of builtin externs to load.
Options: BROWSER, CUSTOM.
Default value is: BROWSER.
User property is: closureEnvironment.
<closureExternDeclarations> ArrayList<FileSet> 2.16.0 List of JavaScript files containing code that declares function names or other symbols. Use closureExterns to preserve symbols that are defined outside of the code you are compiling. The closureExterns parameter only has an effect if you are using a CompilationLevel of ADVANCED_OPTIMIZATIONS.
These file names are relative to baseSourceDir directory.
<closureExternDeclarations>
  <closureExternDeclaration>
    <includes>
      <include>externs/*.js</include>
    </includes>
    <excludes>
      <exclude>externs/doNotInclude.js</exclude>
    </excludes>
  </closureExternDeclaration>
</closureExternDeclarations>

User property is: closureExternDeclarations.
<closureExterns> ArrayList<String> 1.7.2 Deprecated. Deprecated, use closureExternDeclarations instead, it lets you specify includes and excludes.
User property is: closureExterns.
<closureExtraAnnotations> ArrayList<String> 1.7.5 A whitelist of tag names in JSDoc. Needed to support JSDoc extensions like ngdoc.
User property is: closureExtraAnnotations.
<closureForceInjectLibs> ArrayList<String> 2.1.0 Force injection of named runtime libraries. The format is <name> where <name> is the name of a runtime library. Possible libraries include: base, es6_runtime, runtime_type_check
User property is: closureForceInjectLibs.
<closureIncludeSourcesContent> boolean 2.0.0 If true, include the content of the source file in the source map directly (via the sourceContent property). This makes the source file bigger, but does not require the original source file to be added to the browser dev tools.
Default value is: false.
User property is: closureIncludeSourcesContent.
<closureInjectLibraries> boolean 2.1.0 Allow injecting runtime libraries.
Default value is: true.
User property is: closureInjectLibraries.
<closureIsolatePolyfills> boolean 2.23.0 Whether to isolate polyfills from the global scope.

Polyfill isolation is an output mode that may optionally be used alongside polyfill injection.

Polyfill isolation was motivated by two related issues.

  • sometimes, the existence of Closure polyfills on the page would cause other non-Closure-compiled code to break, because of conflicting assumptions in a polyfill implementation used by third-party code.
  • sometimes, Closure-compiled code would break, because of existing polyfills on the page that violated some assumption Closure Compiler makes.
These issues were generally seen by projects compiling code for inclusion as a script on third-party websites, along with arbitrary JavaScript not under their control.

Polyfill isolation mode attempts to solve these problems by "isolating" Closure polyfills and code from other code & polyfills. It is not intended to protect against malicious actors; it is instead intended to solve cases where other polyfill implementations are either buggy or (more likely) make conflicting assumptions.


Default value is: false.
User property is: closureIsolatePolyfills.
<closureJsModuleRoots> ArrayList<String> 2.5.0 Path prefixes to be removed from ES6 & CommonJS modules.
User property is: closureJsModuleRoots.
<closureLanguageIn> CompilerOptions$LanguageMode 1.7.2 Refers to which version of ECMAScript to assume when checking for errors in your code.
Possible values are:
  • ECMASCRIPT3: Checks code assuming ECMAScript 3 compliance, and gives errors for code using features only present in later versions of ECMAScript.
  • ECMASCRIPT5: Checks code assuming ECMAScript 5 compliance, allowing new features not present in ECMAScript 3, and gives errors for code using features only present in later versions of ECMAScript.
  • ECMASCRIPT5_STRICT: Like ECMASCRIPT5 but assumes compliance with strict mode ('use strict';).
  • ECMASCRIPT_2015: Checks code assuming ECMAScript 2015 compliance.
  • ECMASCRIPT_2016: Checks code assuming ECMAScript 2016 compliance.
  • ECMASCRIPT_2017: Checks code assuming ECMAScript 2017 compliance.
  • ECMASCRIPT_2018: Checks code assuming ECMAScript 2018 compliance.
  • ECMASCRIPT_2019: Checks code assuming ECMAScript 2019 compliance.
  • ECMASCRIPT_2020: Checks code assuming ECMAScript 2020 compliance.
  • ECMASCRIPT_2021: Checks code assuming ECMAScript 2021 compliance.
  • ECMASCRIPT_NEXT: Checks code assuming ECMAScript latest draft standard.
  • STABLE Use stable features

Default value is: ECMASCRIPT_NEXT.
User property is: closureLanguageIn.
<closureLanguageOut> CompilerOptions$LanguageMode 1.7.5 Refers to which version of ECMAScript your code will be returned in.
It is used to transpile between different levels of ECMAScript. Possible values are
  • ECMASCRIPT3: Outputs code with ECMAScript 3 compliance.
  • ECMASCRIPT5: Outputs code with ECMAScript 2015.
  • ECMASCRIPT5_STRICT: Like ECMASCRIPT5 but assumes compliance with strict mode ('use strict';).
  • ECMASCRIPT_2015: Outputs code with ECMAScript 2015.
  • ECMASCRIPT_2016: Outputs code with ECMAScript 2016.
  • ECMASCRIPT_2017: Outputs code with ECMAScript 2017.
  • ECMASCRIPT_2018: Outputs code with ECMAScript 2018.
  • ECMASCRIPT_2019: Outputs code with ECMAScript 2019.
  • STABLE: Use stable features
  • NO_TRANSPILE: Do not perform any transpilation.

Default value is: ECMASCRIPT_2015.
User property is: closureLanguageOut.
<closureModuleResolution> ModuleLoader$ResolutionMode 2.1.0 Specifies how the compiler locates modules.
  • BROWSER: Requires all module imports to begin with a '.' or '/' and have a file extension. Mimics the behavior of MS Edge.
  • BROWSER_WITH_TRANSFORMED_PREFIXES: A limited superset of BROWSER that transforms some path prefixes. For example, one could configure this so that "@root/" is replaced with "/my/path/to/project/" within import paths.
  • NODE: Uses the node module rules. Modules which do not begin with a "." or "/" character are looked up from the appropriate node_modules folder. Includes the ability to require directories and JSON files. Exact match, then ".js", then ".json" file extensions are searched.
  • WEBPACK: Looks up modules from a special lookup map. Uses a lookup map provided by webpack to locate modules from a numeric id used during import.

Default value is: BROWSER.
User property is: closureModuleResolution.
<closureOutputWrapper> String 2.0.0

If not an empty or blank string, interpolate output into this string at the place denoted by the marker token %output%. Use marker token %output|jsstring% to do js string escaping on the output.

When using this options with a source map, the map is adjusted appropriately to match the code.


User property is: closureOutputWrapper.
<closurePreferSingleQuotes> boolean 2.1.0 Normally, when there are an equal number of single and double quotes in a string, the compiler will use double quotes. Set this to true to prefer single quotes.
Default value is: false.
User property is: closurePreferSingleQuotes.
<closurePrettyPrint> boolean 2.0.0 If true, the processed ("minified") file is pretty printed (formatted with new lines).
Default value is: false.
User property is: closurePrettyPrint.
<closureProcessClosurePrimitives> boolean 2.1.0 Processes built-ins from the Closure library, such as goog.require(), goog.provide(), and goog.exportSymbol( ).
Default value is: true.
User property is: closureProcessClosurePrimitives.
<closureProcessCommonJsModules> boolean 2.1.0 Process CommonJS modules to a concatenable form.
Default value is: false.
User property is: closureProcessCommonJsModules.
<closureRenamePrefixNamespace> String 2.1.0 Specifies the name of an object that will be used to store all non-extern globals.
User property is: closureRenamePrefixNamespace.
<closureRenameVariablePrefix> String 2.1.0 Specifies a prefix that will be prepended to all variables.
User property is: closureRenameVariablePrefix.
<closureRewritePolyfills> boolean 2.0.0 If true, ES6 polyfills are written to the output file (such as for Set, Map etc.)
Default value is: true.
User property is: closureRewritePolyfills.
<closureSourceMapLocationMappings> ArrayList<ClosureSourceMapLocationMapping> 2.20.0 Source map location mapping. This is a prefix mapping from the file system path to the web server path. The source map contains a reference to the original source files; and this may be different on the web server. The location of the source file is always relative to the given sourceDir. This defines a list of replacements. For each source file, the first matching replacement is used. If the source file starts with the prefix as given by the name, it matches and is replaced with the value. For example:
<closureSourceMapLocationMappings>
  <closureSourceMapLocationMapping>
    <name>js/</name>
    <value>/web/www/js</value>
  </closureSourceMapLocationMapping>
</closureSourceMapLocationMappings>
Assume the source files are js/file1.js and js/file2.js. The above replaces them with /web/www/js/file1.js and /web/www/js/file2.js. This is then path that will be used in the source map to reference the original source file. If no location mappings are specified, the path of the source files relative to the created source map is used instead. If you set the name to an empty string, it matches all paths.
User property is: closureSourceMapLocationMappings.
<closureSourceMapName> String 2.0.0 Name of the source map, if one is created. This is interpreted as a relative path to where the processed JavaScript file is written to. By default, the extension .map is added to the minified file. Variables are specified via #{variableName}. To insert a literal #, use ##. The following variables are available:
  • The variable filename is replaced with the name of the minified file
  • The variable extension is replaced with the extension of the file
  • The variable basename is replaced with the basename (name without the extension) of the file.

Default value is: #{filename}.map.
User property is: closureSourceMapName.
<closureSourceMapOutputType> SourceMapOutputType 2.0.0 After creating the source map, the browser needs to find it. There are several options available:
  • reference (the default): Create a source map named [originalFile].map, and add a reference to it in the minified file.
  • file: Just create a source map named [originalFile].map, do not add a reference in the minified file. This may be useful when you want to add the Source-Map HTTP header.
  • inline: Do not write a separate source map file, but instead include the source map content in the minified file (as base64). This makes it easier for the browser to find the source map. Especially useful when used with JSF/Primefaces or other frameworks that do not use standard URLs.

Default value is: reference.
User property is: closureSourceMapOutputType.
<closureStrictModeInput> boolean 2.1.0 Assume input sources are to run in strict mode.
Default value is: true.
User property is: closureStrictModeInput.
<closureTrustedStrings> boolean 2.0.0 If false, converts some characters such as '<' and '>' to '\x3c' and '\x3d' so that they are safe to put inside a script tag in an HTML file.
Default value is: true.
User property is: closureTrustedStrings.
<closureUseTypesForOptimization> boolean 2.1.0 Enable or disable the optimizations based on available type information. Inaccurate type annotations may result in incorrect results.
Default value is: false.
User property is: closureUseTypesForOptimization.
<closureWarningLevel> WarningLevel 2.1.0 Specifies the warning level to use: QUIET, DEFAULT, or VERBOSE. You can override specific warnings via closureWarningLevels.
Default value is: DEFAULT.
User property is: closureWarningLevel.
<closureWarningLevels> HashMap<String,String> 1.7.5 Treat certain warnings as the specified CheckLevel:
  • ERROR: Makes all warnings of the given group to build-breaking error.
  • WARNING: Makes all warnings of the given group a non-breaking warning.
  • OFF: Silences all warnings of the given group.
Example:

<closureWarningLevels>
    <nonStandardJsDocs>OFF</nonStandardJsDocs>
</closureWarningLevels>

For the complete list of diagnostic groups please visit https://github.com/google/closure-compiler/wiki/Warnings.
User property is: closureWarningLevels.
<encoding> String 1.3.2 If a supported character set is specified, it will be used to read the input file. Otherwise, it will assume that the platform's default character set is being used. The output file is encoded using the same character set.
See the IANA Charset Registry for a list of valid encoding types.
Default value is: ${project.build.sourceEncoding}.
User property is: encoding.
Alias is: charset.
<excludes> ArrayList<String> 1.2 JavaScript files to exclude. Specified as fileset patterns which are relative to the JavaScript source directory.
User property is: excludes.
<force> boolean 2.0.0 For each bundle, this plugin performs a check whether the input or output files have changed and skips the execution in case they haven't. Set this flag to true to force the execution.
Default value is: false.
User property is: force.
<includes> ArrayList<String> 1.2 JavaScript files to include. Specified as fileset patterns which are relative to the JavaScript source directory.
User property is: includes.
<lineSeparator> String 2.0.0 The line separator to be used when merging files etc. Defaults to the default system line separator. Special characters are entered escaped. So for example, to use a new line feed as the separator, set this property to \n (two characters, a backslash and the letter n).
User property is: lineSeparator.
<logLevel> LogLevel - By default, messages are logged at the log level set by maven. This option allows you to change the log level. Valid options are all, debug, info, warn, error, none. Leave empty to use the default log level. Please note that you can only decrease, not increase, the log level.
User property is: logLevel.
<outputFilename> String 2.0.0 The output file name of the processed files. This is interpreted as a path relative to the targetDir.

Variables are specified via #{variableName}. To insert a literal #, use ##. The following variables are supported:

  • The variable filename is replaced with the name of the minified file.
  • The variable extension is replaced with the extension of the file (without the period)
  • The variable basename is replaced with the basename (name without the extension) of the file.
  • In case the files are not merged (option skipMerge is activated): The variable path is replaced with the path of the current file, relative to the sourceDir.

If merging files, by default the basename is set to script and the extension to js, so that the resulting merged file is called script.min.js.


Default value is: #{path}/#{basename}.min.#{extension}.
User property is: outputFilename.
<skip> boolean 2.7.0 When set to `true`, the plugin exits immediately without doing any work at all.
Default value is: false.
User property is: skip.
<skipMerge> boolean 1.5.2 Skip the merge step. Minification will be applied to each source file individually.
Default value is: false.
User property is: skipMerge.
<skipMinify> boolean 1.5.2 Skip the minify step. Useful when merging files that are already minified.
Default value is: false.
User property is: skipMinify.
<skipMode> SkipMode 2.9.0 This options lets configure how this plugin checks whether it should skip an execution in case the target file exists already. Usually you do not want to spend unneccesary processing time on transpiling JavaScript files when the input files themeselves have not changed. Available options are:
  • NEWER - Skip execution if the the target file exists already and all input files are older. Whether a file is older is judged according to their modification date.
  • EXISTS - Skip execution if the target file exists already, irrespective of when thee files were last modified.
These options only apply when force is set to false. In case you never want to skip execution, set the the option force to true.
Default value is: NEWER.
User property is: skipMode.
<skipRunOnIncremental> boolean -

When this plugin is executed as part of an m2e incremental build and this option is set to true, skip the execution of this plugin.

For the m2e integration, this plugin is configured by default to run on incremental builds. When having a project opened in Eclipse, this recreates the minified files every time a source file is changed.

You can disable this behavior via the org.eclipse.m2e/lifefycle-mapping plugin. As this is rather verbose, this option offers a convenient way of disabling incremental builds. Please note that tecnically this plugin is still executed on every incremental build cycle, but exits immediately without doing any work.


Default value is: false.
User property is: skipRunOnIncremental.
<sourceDir> String - JavaScript source directory. This is relative to the baseSourceDir.
Default value is: js.
User property is: sourceDir.
<targetDir> String 1.3.2 JavaScript target directory. Takes the same value as jsSourceDir when empty. This is relative to the baseTargetDir.
Default value is: js.
User property is: targetDir.

Parameter Details

<allowReplacingInputFiles>

By default, when the output file is the same as the input file, compilation is terminated with an error. This is done to prevent source files from being overwritten accidentally with a bad configuration. If you are certain you want to replace the input files (such as when the input files themselves are temporary files that have been generated), set this option to true. Defaults to false.

Note: When enabling this option, you might also want to set skipMerge to true and the outputFilename to #{path}/#{basename}.#{extension}.

  • Type: boolean
  • Required: No
  • User Property: allowReplacingInputFiles
  • Default: false

<baseSourceDir>

Base directory for source files. This should be an absolute path; if not, it must be relative to the project base directory. Use variables such as basedir to make it relative to the current directory.
  • Type: java.io.File
  • Required: No
  • User Property: baseSourceDir
  • Default: ${basedir}/src/main/webapp

<baseTargetDir>

Base directory for output files. This should be an absolute path; if not, it must be relative to the project base directory. Use variables such as project.build.directory to make it relative to the current directory.
  • Type: java.io.File
  • Required: No
  • User Property: baseTargetDir
  • Default: ${project.build.directory}/${project.build.finalName}

<bufferSize>

Size of the buffer used to read source files.
  • Type: int
  • Required: No
  • User Property: bufferSize
  • Default: 4096

<bundleConfiguration>

Specify aggregations in an external JSON formatted config file. If not an absolute path, it must be relative to the project base directory.
  • Type: java.lang.String
  • Since: 1.7.5
  • Required: No
  • User Property: bundleConfiguration

<closureAllowDynamicImport>

Enables experimental support for allowing dynamic import expressions import('./path') to pass through the compiler unchanged. Enabling this requires setting closureLanguageOut to at least ECMASCRIPT_2020.
  • Type: boolean
  • Since: 2.21.0
  • Required: No
  • User Property: closureAllowDynamicImport
  • Default: false

<closureAngularPass>

Generate $inject properties for AngularJS for functions annotated with @ngInject.
  • Type: boolean
  • Since: 1.7.3
  • Required: No
  • User Property: closureAngularPass
  • Default: false

<closureAssumeFunctionWrapper>

Enable additional optimizations based on the assumption that the output will be wrapped with a function wrapper. This flag is used to indicate that "global" declarations will not actually be global but instead isolated to the compilation unit. This enables additional optimizations.
  • Type: boolean
  • Since: 2.1
  • Required: No
  • User Property: closureAssumeFunctionWrapper
  • Default: false

<closureChunkOutputType>

Regardless of input type, the compiler will normalize all files and bundle them together. By default, a single output file is produced. However, this may not work for you if your application is really big. In that case, you may want to have the compiler break your code up into multiple chunks that can be loaded separately. You will design your application so that the code you always need gets loaded in an initial chunk, probably from a <script> tag, then that chunk will load others (which may load still others) as needed in order to support the user's actions. (e.g. The user may request a new display view, which requires you to load the code for showing that view.)
  • GLOBAL_NAMESPACE (Chunks as Scripts using a Global Namespace): This is the default option and the compiler will produce standard scripts. This mode is normally paired with the closureOutputWrapper flag for script isolation and the closureRenamePrefixNamespace flag so that symbols can be referenced across chunks.
  • ES_MODULES (Chunks as Ecmacript modules): The compiler will output es modules and cross chunk references will utilize the import and export statements. Since modules have built in isolation and modern browsers know how to load them, this option is by far the easiest.
  • Type: com.google.javascript.jscomp.CompilerOptions$ChunkOutputType
  • Since: 2.27.0
  • Required: No
  • User Property: closureChunkOutputType
  • Default: GLOBAL_NAMESPACE

<closureColorizeErrorOutput>

Whether the error output from the closure compiler is colorized. Color codes may not be supported by all terminals.
  • Type: boolean
  • Since: 2.0.0
  • Required: No
  • User Property: closureColorizeErrorOutput
  • Default: true

<closureCompilationLevel>

The degree of compression and optimization to apply to your JavaScript.
There are three possible compilation levels:
  • WHITESPACE_ONLY: Just removes whitespace and comments from your JavaScript.
  • SIMPLE_OPTIMIZATIONS: Performs compression and optimization that does not interfere with the interaction between the compiled JavaScript and other JavaScript. This level renames only local variables.
  • ADVANCED_OPTIMIZATIONS: Achieves the highest level of compression by renaming symbols in your JavaScript. When using ADVANCED_OPTIMIZATIONS compilation you must perform extra steps to preserve references to external symbols. See Advanced Compilation and Externs for more information about ADVANCED_OPTIMIZATIONS.
  • BUNDLE: Leaves all compiler options unchanged. For advanced usage if you want to seet the releavant options yourself.
  • Type: com.google.javascript.jscomp.CompilationLevel
  • Since: 1.7.2
  • Required: No
  • User Property: closureCompilationLevel
  • Default: SIMPLE_OPTIMIZATIONS

<closureCreateSourceMap>

Collects information mapping the generated (compiled) source back to its original source for debugging purposes.
  • Type: boolean
  • Since: 2.1.0
  • Required: No
  • User Property: closureCreateSourceMap
  • Default: false

<closureDebug>

Enable debugging options. Property renaming uses long mangled names which can be mapped back to the original name.
  • Type: boolean
  • Since: 2.1.0
  • Required: No
  • User Property: closureDebug
  • Default: false

<closureDefineReplacements>

Override the value of variables annotated with @define.
The format is:

<define>
    <name>value</name>
</define>

where <name> is the name of a @define variable and value is a JavaScript boolean, number or string literal. That is, use quotation marks to specify a string: "First line\nseconds line"
  • Type: java.util.HashMap<java.lang.String, java.lang.String>
  • Since: 1.7.5
  • Required: No
  • User Property: closureDefineReplacements

<closureDependencyEntryPoints>

When you use closureDependencyMode PRUNE or PRUNE_LEGACY, you must specify to the compiler what the entry points of your application are. Beginning at those entry points, it will trace through the files to discover what sources are actually referenced and will drop all other files.

Adds a collection of symbols to always keep. In dependency pruning mode, we will automatically keep all the transitive dependencies of these symbols. The syntactic form of a symbol depends on the type of dependency primitives we're using. For example, goog.provide('foo.bar') provides the symbol foo.bar. Entry points can be scoped to a module by specifying mod2:foo.bar.

There are two different types of entry points, closures and modules:

  • closure: A closure namespace used as an entry point. May start with goog: when provided as a flag from the command line. Closure entry points may also be formatted as: goog:moduleName:name.space which specifies that the module name and provided namespace are different
  • file: Must start with the prefix file:. AES6 or CommonJS modules used as an entry point. The file path is relative to the sourceDir.
  • Type: java.util.ArrayList<java.lang.String>
  • Since: 2.0.0
  • Required: No
  • User Property: closureDependencyEntryPoints

<closureDependencyMode>

How compiler should prune files based on the provide-require dependency graph.
  • NONE All input files will be included in the compilation in the order they were specified in.
  • SORT_ONLY All input files will be included in the compilation in dependency order.
  • PRUNE Input files that are transitive dependencies of the entry points will be included in the compilation in dependency order. All other input files will be dropped. All entry points must be explicitly defined.
  • PRUNE_LEGACY (deprecated) Input files that are transitive dependencies of the entry points will be included in the compilation in dependency order. All other input files will be dropped. In addition to the explicitly defined entry points, moochers (files not explicitly defining a module) are implicit entry points.
  • Type: com.github.blutorange.maven.plugin.closurecompiler.common.DependencyModeFlag
  • Since: 2.0.0
  • Required: No
  • User Property: closureDependencyMode
  • Default: NONE

<closureDynamicImportAlias>

Instructs the compiler to replace dynamic import expressions with a function call using the specified name. This allows dynamic import expressions to be externally polyfilled when the output language level does not natively support them.
  • Type: java.lang.String
  • Since: 2.22.0
  • Required: No
  • User Property: closureDynamicImportAlias

<closureEmitUseStrict>

Start output with 'use strict';.
  • Type: boolean
  • Since: 2.1.0
  • Required: No
  • User Property: closureEmitUseStrict
  • Default: true

<closureEnvironment>

Determines the set of builtin externs to load.
Options: BROWSER, CUSTOM.
  • Type: com.google.javascript.jscomp.CompilerOptions$Environment
  • Since: 1.7.5
  • Required: No
  • User Property: closureEnvironment
  • Default: BROWSER

<closureExternDeclarations>

List of JavaScript files containing code that declares function names or other symbols. Use closureExterns to preserve symbols that are defined outside of the code you are compiling. The closureExterns parameter only has an effect if you are using a CompilationLevel of ADVANCED_OPTIMIZATIONS.
These file names are relative to baseSourceDir directory.
<closureExternDeclarations>
  <closureExternDeclaration>
    <includes>
      <include>externs/*.js</include>
    </includes>
    <excludes>
      <exclude>externs/doNotInclude.js</exclude>
    </excludes>
  </closureExternDeclaration>
</closureExternDeclarations>
  • Type: java.util.ArrayList<com.github.blutorange.maven.plugin.closurecompiler.plugin.FileSet>
  • Since: 2.16.0
  • Required: No
  • User Property: closureExternDeclarations

<closureExterns>

Deprecated. No reason given
Deprecated, use closureExternDeclarations instead, it lets you specify includes and excludes.
  • Type: java.util.ArrayList<java.lang.String>
  • Since: 1.7.2
  • Required: No
  • User Property: closureExterns

<closureExtraAnnotations>

A whitelist of tag names in JSDoc. Needed to support JSDoc extensions like ngdoc.
  • Type: java.util.ArrayList<java.lang.String>
  • Since: 1.7.5
  • Required: No
  • User Property: closureExtraAnnotations

<closureForceInjectLibs>

Force injection of named runtime libraries. The format is <name> where <name> is the name of a runtime library. Possible libraries include: base, es6_runtime, runtime_type_check
  • Type: java.util.ArrayList<java.lang.String>
  • Since: 2.1.0
  • Required: No
  • User Property: closureForceInjectLibs

<closureIncludeSourcesContent>

If true, include the content of the source file in the source map directly (via the sourceContent property). This makes the source file bigger, but does not require the original source file to be added to the browser dev tools.
  • Type: boolean
  • Since: 2.0.0
  • Required: No
  • User Property: closureIncludeSourcesContent
  • Default: false

<closureInjectLibraries>

Allow injecting runtime libraries.
  • Type: boolean
  • Since: 2.1.0
  • Required: No
  • User Property: closureInjectLibraries
  • Default: true

<closureIsolatePolyfills>

Whether to isolate polyfills from the global scope.

Polyfill isolation is an output mode that may optionally be used alongside polyfill injection.

Polyfill isolation was motivated by two related issues.

  • sometimes, the existence of Closure polyfills on the page would cause other non-Closure-compiled code to break, because of conflicting assumptions in a polyfill implementation used by third-party code.
  • sometimes, Closure-compiled code would break, because of existing polyfills on the page that violated some assumption Closure Compiler makes.
These issues were generally seen by projects compiling code for inclusion as a script on third-party websites, along with arbitrary JavaScript not under their control.

Polyfill isolation mode attempts to solve these problems by "isolating" Closure polyfills and code from other code & polyfills. It is not intended to protect against malicious actors; it is instead intended to solve cases where other polyfill implementations are either buggy or (more likely) make conflicting assumptions.

  • Type: boolean
  • Since: 2.23.0
  • Required: No
  • User Property: closureIsolatePolyfills
  • Default: false

<closureJsModuleRoots>

Path prefixes to be removed from ES6 & CommonJS modules.
  • Type: java.util.ArrayList<java.lang.String>
  • Since: 2.5.0
  • Required: No
  • User Property: closureJsModuleRoots

<closureLanguageIn>

Refers to which version of ECMAScript to assume when checking for errors in your code.
Possible values are:
  • ECMASCRIPT3: Checks code assuming ECMAScript 3 compliance, and gives errors for code using features only present in later versions of ECMAScript.
  • ECMASCRIPT5: Checks code assuming ECMAScript 5 compliance, allowing new features not present in ECMAScript 3, and gives errors for code using features only present in later versions of ECMAScript.
  • ECMASCRIPT5_STRICT: Like ECMASCRIPT5 but assumes compliance with strict mode ('use strict';).
  • ECMASCRIPT_2015: Checks code assuming ECMAScript 2015 compliance.
  • ECMASCRIPT_2016: Checks code assuming ECMAScript 2016 compliance.
  • ECMASCRIPT_2017: Checks code assuming ECMAScript 2017 compliance.
  • ECMASCRIPT_2018: Checks code assuming ECMAScript 2018 compliance.
  • ECMASCRIPT_2019: Checks code assuming ECMAScript 2019 compliance.
  • ECMASCRIPT_2020: Checks code assuming ECMAScript 2020 compliance.
  • ECMASCRIPT_2021: Checks code assuming ECMAScript 2021 compliance.
  • ECMASCRIPT_NEXT: Checks code assuming ECMAScript latest draft standard.
  • STABLE Use stable features
  • Type: com.google.javascript.jscomp.CompilerOptions$LanguageMode
  • Since: 1.7.2
  • Required: No
  • User Property: closureLanguageIn
  • Default: ECMASCRIPT_NEXT

<closureLanguageOut>

Refers to which version of ECMAScript your code will be returned in.
It is used to transpile between different levels of ECMAScript. Possible values are
  • ECMASCRIPT3: Outputs code with ECMAScript 3 compliance.
  • ECMASCRIPT5: Outputs code with ECMAScript 2015.
  • ECMASCRIPT5_STRICT: Like ECMASCRIPT5 but assumes compliance with strict mode ('use strict';).
  • ECMASCRIPT_2015: Outputs code with ECMAScript 2015.
  • ECMASCRIPT_2016: Outputs code with ECMAScript 2016.
  • ECMASCRIPT_2017: Outputs code with ECMAScript 2017.
  • ECMASCRIPT_2018: Outputs code with ECMAScript 2018.
  • ECMASCRIPT_2019: Outputs code with ECMAScript 2019.
  • STABLE: Use stable features
  • NO_TRANSPILE: Do not perform any transpilation.
  • Type: com.google.javascript.jscomp.CompilerOptions$LanguageMode
  • Since: 1.7.5
  • Required: No
  • User Property: closureLanguageOut
  • Default: ECMASCRIPT_2015

<closureModuleResolution>

Specifies how the compiler locates modules.
  • BROWSER: Requires all module imports to begin with a '.' or '/' and have a file extension. Mimics the behavior of MS Edge.
  • BROWSER_WITH_TRANSFORMED_PREFIXES: A limited superset of BROWSER that transforms some path prefixes. For example, one could configure this so that "@root/" is replaced with "/my/path/to/project/" within import paths.
  • NODE: Uses the node module rules. Modules which do not begin with a "." or "/" character are looked up from the appropriate node_modules folder. Includes the ability to require directories and JSON files. Exact match, then ".js", then ".json" file extensions are searched.
  • WEBPACK: Looks up modules from a special lookup map. Uses a lookup map provided by webpack to locate modules from a numeric id used during import.
  • Type: com.google.javascript.jscomp.deps.ModuleLoader$ResolutionMode
  • Since: 2.1.0
  • Required: No
  • User Property: closureModuleResolution
  • Default: BROWSER

<closureOutputWrapper>

If not an empty or blank string, interpolate output into this string at the place denoted by the marker token %output%. Use marker token %output|jsstring% to do js string escaping on the output.

When using this options with a source map, the map is adjusted appropriately to match the code.

  • Type: java.lang.String
  • Since: 2.0.0
  • Required: No
  • User Property: closureOutputWrapper

<closurePreferSingleQuotes>

Normally, when there are an equal number of single and double quotes in a string, the compiler will use double quotes. Set this to true to prefer single quotes.
  • Type: boolean
  • Since: 2.1.0
  • Required: No
  • User Property: closurePreferSingleQuotes
  • Default: false

<closurePrettyPrint>

If true, the processed ("minified") file is pretty printed (formatted with new lines).
  • Type: boolean
  • Since: 2.0.0
  • Required: No
  • User Property: closurePrettyPrint
  • Default: false

<closureProcessClosurePrimitives>

Processes built-ins from the Closure library, such as goog.require(), goog.provide(), and goog.exportSymbol( ).
  • Type: boolean
  • Since: 2.1.0
  • Required: No
  • User Property: closureProcessClosurePrimitives
  • Default: true

<closureProcessCommonJsModules>

Process CommonJS modules to a concatenable form.
  • Type: boolean
  • Since: 2.1.0
  • Required: No
  • User Property: closureProcessCommonJsModules
  • Default: false

<closureRenamePrefixNamespace>

Specifies the name of an object that will be used to store all non-extern globals.
  • Type: java.lang.String
  • Since: 2.1.0
  • Required: No
  • User Property: closureRenamePrefixNamespace

<closureRenameVariablePrefix>

Specifies a prefix that will be prepended to all variables.
  • Type: java.lang.String
  • Since: 2.1.0
  • Required: No
  • User Property: closureRenameVariablePrefix

<closureRewritePolyfills>

If true, ES6 polyfills are written to the output file (such as for Set, Map etc.)
  • Type: boolean
  • Since: 2.0.0
  • Required: No
  • User Property: closureRewritePolyfills
  • Default: true

<closureSourceMapLocationMappings>

Source map location mapping. This is a prefix mapping from the file system path to the web server path. The source map contains a reference to the original source files; and this may be different on the web server. The location of the source file is always relative to the given sourceDir. This defines a list of replacements. For each source file, the first matching replacement is used. If the source file starts with the prefix as given by the name, it matches and is replaced with the value. For example:
<closureSourceMapLocationMappings>
  <closureSourceMapLocationMapping>
    <name>js/</name>
    <value>/web/www/js</value>
  </closureSourceMapLocationMapping>
</closureSourceMapLocationMappings>
Assume the source files are js/file1.js and js/file2.js. The above replaces them with /web/www/js/file1.js and /web/www/js/file2.js. This is then path that will be used in the source map to reference the original source file. If no location mappings are specified, the path of the source files relative to the created source map is used instead. If you set the name to an empty string, it matches all paths.
  • Type: java.util.ArrayList<com.github.blutorange.maven.plugin.closurecompiler.plugin.ClosureSourceMapLocationMapping>
  • Since: 2.20.0
  • Required: No
  • User Property: closureSourceMapLocationMappings

<closureSourceMapName>

Name of the source map, if one is created. This is interpreted as a relative path to where the processed JavaScript file is written to. By default, the extension .map is added to the minified file. Variables are specified via #{variableName}. To insert a literal #, use ##. The following variables are available:
  • The variable filename is replaced with the name of the minified file
  • The variable extension is replaced with the extension of the file
  • The variable basename is replaced with the basename (name without the extension) of the file.
  • Type: java.lang.String
  • Since: 2.0.0
  • Required: No
  • User Property: closureSourceMapName
  • Default: #{filename}.map

<closureSourceMapOutputType>

After creating the source map, the browser needs to find it. There are several options available:
  • reference (the default): Create a source map named [originalFile].map, and add a reference to it in the minified file.
  • file: Just create a source map named [originalFile].map, do not add a reference in the minified file. This may be useful when you want to add the Source-Map HTTP header.
  • inline: Do not write a separate source map file, but instead include the source map content in the minified file (as base64). This makes it easier for the browser to find the source map. Especially useful when used with JSF/Primefaces or other frameworks that do not use standard URLs.
  • Type: com.github.blutorange.maven.plugin.closurecompiler.common.SourceMapOutputType
  • Since: 2.0.0
  • Required: No
  • User Property: closureSourceMapOutputType
  • Default: reference

<closureStrictModeInput>

Assume input sources are to run in strict mode.
  • Type: boolean
  • Since: 2.1.0
  • Required: No
  • User Property: closureStrictModeInput
  • Default: true

<closureTrustedStrings>

If false, converts some characters such as '<' and '>' to '\x3c' and '\x3d' so that they are safe to put inside a script tag in an HTML file.
  • Type: boolean
  • Since: 2.0.0
  • Required: No
  • User Property: closureTrustedStrings
  • Default: true

<closureUseTypesForOptimization>

Enable or disable the optimizations based on available type information. Inaccurate type annotations may result in incorrect results.
  • Type: boolean
  • Since: 2.1.0
  • Required: No
  • User Property: closureUseTypesForOptimization
  • Default: false

<closureWarningLevel>

Specifies the warning level to use: QUIET, DEFAULT, or VERBOSE. You can override specific warnings via closureWarningLevels.
  • Type: com.google.javascript.jscomp.WarningLevel
  • Since: 2.1.0
  • Required: No
  • User Property: closureWarningLevel
  • Default: DEFAULT

<closureWarningLevels>

Treat certain warnings as the specified CheckLevel:
  • ERROR: Makes all warnings of the given group to build-breaking error.
  • WARNING: Makes all warnings of the given group a non-breaking warning.
  • OFF: Silences all warnings of the given group.
Example:

<closureWarningLevels>
    <nonStandardJsDocs>OFF</nonStandardJsDocs>
</closureWarningLevels>

For the complete list of diagnostic groups please visit https://github.com/google/closure-compiler/wiki/Warnings.
  • Type: java.util.HashMap<java.lang.String, java.lang.String>
  • Since: 1.7.5
  • Required: No
  • User Property: closureWarningLevels

<encoding>

If a supported character set is specified, it will be used to read the input file. Otherwise, it will assume that the platform's default character set is being used. The output file is encoded using the same character set.
See the IANA Charset Registry for a list of valid encoding types.
  • Type: java.lang.String
  • Since: 1.3.2
  • Required: No
  • User Property: encoding
  • Default: ${project.build.sourceEncoding}
  • Alias: charset

<excludes>

JavaScript files to exclude. Specified as fileset patterns which are relative to the JavaScript source directory.
  • Type: java.util.ArrayList<java.lang.String>
  • Since: 1.2
  • Required: No
  • User Property: excludes

<force>

For each bundle, this plugin performs a check whether the input or output files have changed and skips the execution in case they haven't. Set this flag to true to force the execution.
  • Type: boolean
  • Since: 2.0.0
  • Required: No
  • User Property: force
  • Default: false

<includes>

JavaScript files to include. Specified as fileset patterns which are relative to the JavaScript source directory.
  • Type: java.util.ArrayList<java.lang.String>
  • Since: 1.2
  • Required: No
  • User Property: includes

<lineSeparator>

The line separator to be used when merging files etc. Defaults to the default system line separator. Special characters are entered escaped. So for example, to use a new line feed as the separator, set this property to \n (two characters, a backslash and the letter n).
  • Type: java.lang.String
  • Since: 2.0.0
  • Required: No
  • User Property: lineSeparator

<logLevel>

By default, messages are logged at the log level set by maven. This option allows you to change the log level. Valid options are all, debug, info, warn, error, none. Leave empty to use the default log level. Please note that you can only decrease, not increase, the log level.
  • Type: com.github.blutorange.maven.plugin.closurecompiler.common.LogLevel
  • Required: No
  • User Property: logLevel

<outputFilename>

The output file name of the processed files. This is interpreted as a path relative to the targetDir.

Variables are specified via #{variableName}. To insert a literal #, use ##. The following variables are supported:

  • The variable filename is replaced with the name of the minified file.
  • The variable extension is replaced with the extension of the file (without the period)
  • The variable basename is replaced with the basename (name without the extension) of the file.
  • In case the files are not merged (option skipMerge is activated): The variable path is replaced with the path of the current file, relative to the sourceDir.

If merging files, by default the basename is set to script and the extension to js, so that the resulting merged file is called script.min.js.

  • Type: java.lang.String
  • Since: 2.0.0
  • Required: No
  • User Property: outputFilename
  • Default: #{path}/#{basename}.min.#{extension}

<skip>

When set to `true`, the plugin exits immediately without doing any work at all.
  • Type: boolean
  • Since: 2.7.0
  • Required: No
  • User Property: skip
  • Default: false

<skipMerge>

Skip the merge step. Minification will be applied to each source file individually.
  • Type: boolean
  • Since: 1.5.2
  • Required: No
  • User Property: skipMerge
  • Default: false

<skipMinify>

Skip the minify step. Useful when merging files that are already minified.
  • Type: boolean
  • Since: 1.5.2
  • Required: No
  • User Property: skipMinify
  • Default: false

<skipMode>

This options lets configure how this plugin checks whether it should skip an execution in case the target file exists already. Usually you do not want to spend unneccesary processing time on transpiling JavaScript files when the input files themeselves have not changed. Available options are:
  • NEWER - Skip execution if the the target file exists already and all input files are older. Whether a file is older is judged according to their modification date.
  • EXISTS - Skip execution if the target file exists already, irrespective of when thee files were last modified.
These options only apply when force is set to false. In case you never want to skip execution, set the the option force to true.
  • Type: com.github.blutorange.maven.plugin.closurecompiler.plugin.SkipMode
  • Since: 2.9.0
  • Required: No
  • User Property: skipMode
  • Default: NEWER

<skipRunOnIncremental>

When this plugin is executed as part of an m2e incremental build and this option is set to true, skip the execution of this plugin.

For the m2e integration, this plugin is configured by default to run on incremental builds. When having a project opened in Eclipse, this recreates the minified files every time a source file is changed.

You can disable this behavior via the org.eclipse.m2e/lifefycle-mapping plugin. As this is rather verbose, this option offers a convenient way of disabling incremental builds. Please note that tecnically this plugin is still executed on every incremental build cycle, but exits immediately without doing any work.

  • Type: boolean
  • Required: No
  • User Property: skipRunOnIncremental
  • Default: false

<sourceDir>

JavaScript source directory. This is relative to the baseSourceDir.
  • Type: java.lang.String
  • Required: No
  • User Property: sourceDir
  • Default: js

<targetDir>

JavaScript target directory. Takes the same value as jsSourceDir when empty. This is relative to the baseTargetDir.
  • Type: java.lang.String
  • Since: 1.3.2
  • Required: No
  • User Property: targetDir
  • Default: js