├── .gitattributes ├── .gitignore ├── .mvn └── wrapper │ └── maven-wrapper.properties ├── CHANGELOG.md ├── LICENSE ├── README.md ├── eclipse-java-google-style.xml ├── hooks └── pre-commit.sh ├── mvnw ├── mvnw.cmd ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── github │ │ └── blutorange │ │ └── maven │ │ └── plugin │ │ └── closurecompiler │ │ ├── common │ │ ├── Aggregation.java │ │ ├── AggregationConfiguration.java │ │ ├── ClosureCompileFileMessage.java │ │ ├── ClosureConfig.java │ │ ├── FileException.java │ │ ├── FileHelper.java │ │ ├── FileMessage.java │ │ ├── FileProcessConfig.java │ │ ├── FileSpecifier.java │ │ ├── FileSystemLocationMapping.java │ │ ├── FilenameInterpolator.java │ │ ├── HtmlModifier.java │ │ ├── HtmlUpdater.java │ │ ├── LogWrapper.java │ │ ├── OutputInterpolator.java │ │ ├── ProcessFilesTask.java │ │ ├── ProcessJSFilesTask.java │ │ ├── ProcessingResult.java │ │ ├── SourceFilesEnumeration.java │ │ ├── TextFileModification.java │ │ └── TextFileModifications.java │ │ ├── plugin │ │ ├── ClosureSourceMapLocationMapping.java │ │ ├── DependencyModeFlag.java │ │ ├── FileSet.java │ │ ├── HtmlUpdate.java │ │ ├── HtmlUpdateConfigImpl.java │ │ ├── LogLevel.java │ │ ├── MinifyMojo.java │ │ ├── MojoMetaImpl.java │ │ ├── SkipMode.java │ │ └── SourceMapOutputType.java │ │ └── shared │ │ ├── HtmlUpdateConfig.java │ │ └── MojoMetadata.java └── resources │ └── META-INF │ └── m2e │ └── lifecycle-mapping-metadata.xml ├── site ├── apt │ ├── examples │ │ ├── basic.apt │ │ ├── exclude.apt │ │ ├── m2e.apt │ │ ├── patterns.apt │ │ └── watch.apt │ ├── index.apt │ └── usage.apt ├── fml │ └── faq.fml ├── markdown │ └── examples │ │ ├── bundle.md │ │ └── htmlUpdate.md └── site.xml └── test ├── java └── com │ └── github │ └── blutorange │ └── maven │ └── plugin │ └── closurecompiler │ ├── common │ └── HtmlModifierTest.java │ └── test │ ├── ChainedPrintStream.java │ ├── MinifyMojoTest.java │ └── NoOpOutputStream.java └── resources ├── logback-test.xml └── projects ├── allowdynamicimport ├── expected │ ├── dynamic-imports-extern.js │ ├── dynamic-imports-false.js │ └── dynamic-imports-true.js ├── pom.xml └── test │ ├── extern │ └── dynamic-import-extern.js │ ├── false │ ├── dynamic-import-false.js │ └── import.js │ └── true │ ├── dynamic-import-true.js │ └── import.js ├── assumeFunctionWrapper ├── expected │ ├── assume-function-wrapper-false.js │ └── assume-function-wrapper-true.js ├── pom.xml └── test │ └── script.js ├── bundle ├── bundles │ └── minify.json ├── expected │ └── app-min.js ├── pom.xml └── test │ ├── app.js │ └── includes │ └── model │ └── vector.js ├── compilationlevel ├── expected │ ├── advanced.js │ ├── simple.js │ └── whitespace.js ├── pom.xml └── test │ └── script.js ├── define ├── expected │ └── script.min.js ├── pom.xml └── test │ └── define.js ├── dynamicimportalias ├── expected │ └── aliased.js ├── pom.xml └── test │ ├── dynamic-import-alias.js │ └── import.js ├── emitusestrict ├── expected │ ├── script.js │ └── script.strict.js ├── pom.xml └── test │ └── table.js ├── externs ├── expected │ └── with-externs.js ├── externs │ └── extern.js ├── pom.xml └── test │ └── script.js ├── gzip-compression ├── expected │ ├── merge_minify │ │ ├── out.js │ │ └── out.js.gz │ ├── merge_nominify │ │ ├── out.js │ │ └── out.js.gz │ ├── nomerge_minify │ │ ├── a.js │ │ ├── a.js.gz │ │ ├── b.js │ │ └── b.js.gz │ └── nomerge_nominify │ │ ├── a.js │ │ ├── a.js.gz │ │ ├── b.js │ │ └── b.js.gz ├── pom.xml └── test │ ├── a.js │ └── b.js ├── htmlUpdate ├── encoding.txt ├── expected │ ├── node_js │ │ └── web │ │ │ └── js │ │ │ ├── pageAttributes │ │ │ └── page-attributes.min.js │ │ │ ├── pageBasic │ │ │ └── page-basic.min.js │ │ │ ├── pageHtmlDir │ │ │ └── page-html-dir.min.js │ │ │ ├── pageHtmlEncoding │ │ │ └── page-html-文字符号化方式.min.js │ │ │ ├── pageHtmlFiles │ │ │ └── page-html-files.min.js │ │ │ ├── pageRoot │ │ │ └── page-root.min.js │ │ │ ├── pageScriptSelector │ │ │ ├── css │ │ │ │ └── page-selector-css.min.js │ │ │ ├── id │ │ │ │ └── page-selector-id.min.js │ │ │ └── xpath │ │ │ │ └── page-selector-xpath.min.js │ │ │ ├── pageSourcePath │ │ │ └── page-source-path.min.js │ │ │ ├── pageSourcePathGlobal │ │ │ └── page-source-path-global.min.js │ │ │ ├── pageUsePhysicalRoot │ │ │ └── page-use-physical-root.min.js │ │ │ ├── pageUsePhysicalRootGlobal │ │ │ └── page-use-physical-root-global.min.js │ │ │ ├── pageXhtmlFile │ │ │ └── page-xhtml-file.min.js │ │ │ └── pageXmlFile │ │ │ └── page-xml-file.min.js │ └── template_builder │ │ └── web │ │ └── html │ │ ├── pageAttributes │ │ └── index-page-attributes.html │ │ ├── pageBasic │ │ └── index-page-basic.html │ │ ├── pageHtmlDir │ │ └── index-page-html-dir.html │ │ ├── pageHtmlEncoding │ │ └── index-page-html-encoding.html │ │ ├── pageHtmlFiles │ │ ├── a │ │ │ ├── index-a1-exclude.html │ │ │ ├── index-a1-include.html │ │ │ ├── index-a2-exclude.html │ │ │ └── index-a2-include.html │ │ └── b │ │ │ ├── index-b1-exclude.html │ │ │ ├── index-b1-include.html │ │ │ ├── index-b2-exclude.html │ │ │ └── index-b2-include.html │ │ ├── pageRoot │ │ └── index-page-root.html │ │ ├── pageScriptSelector │ │ ├── css │ │ │ └── index-selector-css.html │ │ ├── id │ │ │ └── index-selector-id.html │ │ └── xpath │ │ │ └── index-selector-xpath.html │ │ ├── pageSourcePath │ │ └── index-page-source-path.html │ │ ├── pageSourcePathGlobal │ │ └── index-page-source-path-global.html │ │ ├── pageUsePhysicalRoot │ │ └── index-page-use-physical-root.html │ │ ├── pageUsePhysicalRootGlobal │ │ └── index-page-use-physical-root-global.html │ │ ├── pageXhtmlFile │ │ └── index-page-xhtml-file.xhtml │ │ └── pageXmlFile │ │ └── index-page-xml-file.xml ├── pom.xml ├── src │ └── main │ │ └── resources │ │ └── web │ │ └── html │ │ ├── pageAttributes │ │ └── index-page-attributes.html │ │ ├── pageBasic │ │ └── index-page-basic.html │ │ ├── pageHtmlDir │ │ └── index-page-html-dir.html │ │ ├── pageHtmlEncoding │ │ └── index-page-html-encoding.html │ │ ├── pageHtmlFiles │ │ ├── a │ │ │ ├── index-a1-exclude.html │ │ │ ├── index-a1-include.html │ │ │ ├── index-a2-exclude.html │ │ │ └── index-a2-include.html │ │ └── b │ │ │ ├── index-b1-exclude.html │ │ │ ├── index-b1-include.html │ │ │ ├── index-b2-exclude.html │ │ │ └── index-b2-include.html │ │ ├── pageRoot │ │ └── index-page-root.html │ │ ├── pageScriptSelector │ │ ├── css │ │ │ └── index-selector-css.html │ │ ├── id │ │ │ └── index-selector-id.html │ │ └── xpath │ │ │ └── index-selector-xpath.html │ │ ├── pageSourcePath │ │ └── index-page-source-path.html │ │ ├── pageSourcePathGlobal │ │ └── index-page-source-path-global.html │ │ ├── pageUsePhysicalRoot │ │ └── index-page-use-physical-root.html │ │ ├── pageUsePhysicalRootGlobal │ │ └── index-page-use-physical-root-global.html │ │ ├── pageXhtmlFile │ │ └── index-page-xhtml-file.xhtml │ │ └── pageXmlFile │ │ └── index-page-xml-file.xml └── test │ └── web │ └── js │ ├── pageAttributes │ └── page-attributes.js │ ├── pageBasic │ └── page-basic.js │ ├── pageHtmlDir │ └── page-html-dir.js │ ├── pageHtmlEncoding │ └── page-html-文字符号化方式.js │ ├── pageHtmlFiles │ └── page-html-files.js │ ├── pageRoot │ └── page-root.js │ ├── pageScriptSelector │ ├── css │ │ └── page-selector-css.js │ ├── id │ │ └── page-selector-id.js │ └── xpath │ │ └── page-selector-xpath.js │ ├── pageSourcePath │ └── page-source-path.js │ ├── pageSourcePathGlobal │ └── page-source-path-global.js │ ├── pageUsePhysicalRoot │ └── page-use-physical-root.js │ ├── pageUsePhysicalRootGlobal │ └── page-use-physical-root-global.js │ ├── pageXhtmlFile │ └── page-xhtml-file.js │ └── pageXmlFile │ └── page-xml-file.js ├── isolatepolyfills ├── expected │ ├── isolate-polyfills-false.js │ └── isolate-polyfills-true.js ├── pom.xml └── test │ └── map-set.js ├── jquery ├── expected │ └── script.min.js ├── pom.xml └── test │ └── jquery.js ├── minimal ├── expected │ └── script.min.js ├── pom.xml └── test │ └── hello.js ├── nodemodules ├── expected │ ├── default.js │ └── jsmoduleroot.js ├── pom.xml └── test │ ├── default │ ├── main.js │ ├── node_modules │ │ └── to-array │ │ │ ├── .npmignore │ │ │ ├── LICENCE │ │ │ ├── README.md │ │ │ ├── index.js │ │ │ └── package.json │ ├── package-lock.json │ └── package.json │ └── jsmoduleroot │ ├── main.js │ ├── npm │ └── node_modules │ │ └── to-array │ │ ├── .npmignore │ │ ├── LICENCE │ │ ├── README.md │ │ ├── index.js │ │ └── package.json │ ├── package-lock.json │ └── package.json ├── outputfilename ├── expected │ ├── merge+minify.js │ ├── merge-only.js │ ├── minify-only-hello1.js │ ├── minify-only-hello2.js │ ├── minify-only-hello3.js │ ├── no-merge-no-minify-hello1.js │ ├── no-merge-no-minify-hello2.js │ ├── no-merge-no-minify-hello3.js │ ├── placeholder-extension-hello-mjs.js │ ├── placeholder-filename-hello1.js │ ├── placeholder-filename-hello2.js │ ├── placeholder-filename-hello3.js │ └── placeholder-path-subdir-hello3.js ├── pom.xml └── test │ ├── hello.mjs │ ├── hello1.js │ ├── hello2.js │ └── subdir │ └── hello3.js ├── outputwrapper ├── expected │ ├── jsstring.js │ └── simple.js ├── pom.xml └── test │ └── onDocumentReady.js ├── overwriteInputFilesDisabled ├── pom.xml └── test │ ├── fileC.js │ ├── subDirA │ ├── fileA.js │ └── nested │ │ └── fileD.js │ └── subDirB │ └── fileB.js ├── overwriteInputFilesEnabled ├── expected │ ├── fileC.js │ ├── subDirA │ │ ├── fileA.js │ │ └── nested │ │ │ └── fileD.js │ └── subDirB │ │ └── fileB.js ├── pom.xml └── test │ ├── fileC.js │ ├── subDirA │ ├── fileA.js │ └── nested │ │ └── fileD.js │ └── subDirB │ └── fileB.js ├── parent └── pom.xml ├── prefersinglequotes ├── expected │ ├── prefer-single-quotes-false.js │ └── prefer-single-quotes-true.js ├── pom.xml └── test │ └── hello.js ├── prettyprint ├── expected │ ├── script.js │ └── script.min.js ├── pom.xml └── test │ └── hello.js ├── rewritepolyfills ├── expected │ ├── no-map-set.js │ ├── polyfills-false.js │ └── polyfills-true.js ├── pom.xml └── test │ ├── map-set.js │ └── no-map-set.js ├── skip ├── expected │ ├── default.js │ ├── hello.js │ ├── hello2.js │ ├── skipBoth │ │ ├── hello.js │ │ └── hello2.js │ └── skipMinify.js ├── pom.xml └── test │ ├── hello.js │ └── hello2.js ├── skipall ├── expected │ └── nofiles ├── pom.xml └── test │ └── hello.js ├── skipif ├── expected │ └── script.min.js ├── newer │ └── script.min.js ├── pom.xml └── test │ └── hello.js ├── skipsome ├── existing │ ├── script1.min.js │ ├── script3.min.js │ └── script4.min.js ├── expected │ ├── script1.min.js │ ├── script2.min.js │ ├── script3.min.js │ ├── script4.min.js │ └── script5.min.js ├── pom.xml └── test │ ├── script1.js │ ├── script2.js │ ├── script3.js │ ├── script4.js │ └── script5.js ├── sourcemap ├── expected │ ├── file.js │ ├── file.js.map │ ├── inline-content.js │ ├── inline.js │ ├── location-mapping-empty.js │ ├── location-mapping-empty.js.map │ ├── location-mapping.js │ ├── location-mapping.js.map │ ├── map-path.js │ ├── reference.js │ ├── reference.js.map │ └── sourcemap │ │ └── map-path.js.map ├── pom.xml ├── test │ └── sample.js └── test2 │ └── js │ └── sample.js ├── subdirs ├── expected │ └── resources │ │ ├── js │ │ └── f1 │ │ │ ├── file1.min.js │ │ │ ├── file2.min.js │ │ │ └── file3.min.js │ │ └── scripts │ │ └── file4.min.js ├── pom.xml └── test │ └── resources │ ├── js │ └── f1 │ │ ├── file1.js │ │ ├── file2.js │ │ └── file3.js │ └── scripts │ └── file4.js ├── trustedstrings ├── expected │ ├── trusted-false.js │ └── trusted-true.js ├── pom.xml └── test │ └── hello.js └── usetypesforoptimization ├── expected ├── script.js └── script.optim.js ├── pom.xml └── test └── script.js /.gitattributes: -------------------------------------------------------------------------------- 1 | # We'll let Git's auto-detection algorithm infer if a file is text. If it is, 2 | # enforce LF line endings regardless of OS or git configurations. 3 | * text=auto eol=lf 4 | 5 | # Isolate binary files in case the auto-detection algorithm fails and 6 | # marks them as text files (which could brick them). 7 | *.{png,jpg,jpeg,gif,webp,woff,woff2} binary 8 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /hooks/pre-commit.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | stagedFiles=$(git diff --staged --name-only) 4 | 5 | mvn spotless:apply || exit 1 6 | 7 | for file in $stagedFiles; do 8 | if test -f "$file"; then 9 | git add $file 10 | fi 11 | done 12 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/common/Aggregation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Closure Compiler Maven Plugin https://github.com/blutorange/closure-compiler-maven-plugin Original license terms 3 | * below. Changes were made to this file. 4 | */ 5 | 6 | /* 7 | * Minify Maven Plugin https://github.com/samaxes/minify-maven-plugin Copyright (c) 2009 samaxes.com Licensed under the 8 | * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may 9 | * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or 10 | * agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 11 | * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions 12 | * and limitations under the License. 13 | */ 14 | package com.github.blutorange.maven.plugin.closurecompiler.common; 15 | 16 | import java.util.Collections; 17 | import java.util.List; 18 | 19 | /** Maps a single bundle defined in {@link AggregationConfiguration}. */ 20 | public class Aggregation { 21 | 22 | private String name; 23 | 24 | private List includes = Collections.emptyList(); 25 | 26 | private List excludes = Collections.emptyList(); 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | 36 | public List getIncludes() { 37 | return includes; 38 | } 39 | 40 | public void setIncludes(List files) { 41 | this.includes = files; 42 | } 43 | 44 | public List getExcludes() { 45 | return excludes; 46 | } 47 | 48 | public void setExcludes(List excludes) { 49 | this.excludes = excludes; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/common/AggregationConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Closure Compiler Maven Plugin https://github.com/blutorange/closure-compiler-maven-plugin Original license terms 3 | * below. Changes were made to this file. 4 | */ 5 | 6 | /* 7 | * Minify Maven Plugin https://github.com/samaxes/minify-maven-plugin Copyright (c) 2009 samaxes.com Licensed under the 8 | * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may 9 | * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or 10 | * agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 11 | * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions 12 | * and limitations under the License. 13 | */ 14 | package com.github.blutorange.maven.plugin.closurecompiler.common; 15 | 16 | import java.util.List; 17 | 18 | /** Maps aggregations from an external JSON formatted config file defined in the option {@code bundleConfiguration}. */ 19 | public class AggregationConfiguration { 20 | 21 | private List bundles; 22 | 23 | /** 24 | * Gets the bundles. 25 | * 26 | * @return the bundles 27 | */ 28 | public List getBundles() { 29 | return bundles; 30 | } 31 | 32 | /** 33 | * Sets the bundles. 34 | * 35 | * @param bundles the bundles to set 36 | */ 37 | public void setBundles(List bundles) { 38 | this.bundles = bundles; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/common/ClosureCompileFileMessage.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.common; 2 | 3 | import com.google.debugging.sourcemap.proto.Mapping.OriginalMapping; 4 | import com.google.javascript.jscomp.Compiler; 5 | import com.google.javascript.jscomp.JSError; 6 | import java.io.File; 7 | import org.apache.commons.lang3.StringUtils; 8 | import org.sonatype.plexus.build.incremental.BuildContext; 9 | 10 | final class ClosureCompileFileMessage extends FileMessage { 11 | private ClosureCompileFileMessage(File file, int line, int column, String message, int severity, Throwable cause) { 12 | super(file, line, column, message, severity, cause); 13 | } 14 | 15 | private static FileMessage of(JSError error, Compiler compiler, File baseDir, int severity) { 16 | String message = format(compiler, error, severity, false); 17 | File file = StringUtils.isNotEmpty(error.getSourceName()) ? new File(baseDir, error.getSourceName()) : baseDir; 18 | return new ClosureCompileFileMessage(file, error.getLineNumber(), error.getCharno(), message, severity, null); 19 | } 20 | 21 | public static FileMessage ofError(JSError error, Compiler compiler, File baseDir) { 22 | return of(error, compiler, baseDir, BuildContext.SEVERITY_ERROR); 23 | } 24 | 25 | public static FileMessage ofWarning(JSError error, Compiler compiler, File baseDir) { 26 | return of(error, compiler, baseDir, BuildContext.SEVERITY_WARNING); 27 | } 28 | 29 | private static String format(Compiler source, JSError error, int severity, boolean includeLocation) { 30 | String sourceName = error.getSourceName(); 31 | int lineNumber = error.getLineNumber(); 32 | 33 | // Format the non-reverse-mapped position. 34 | StringBuilder b = new StringBuilder(); 35 | StringBuilder boldLine = new StringBuilder(); 36 | String nonMappedPosition = formatPosition(sourceName, lineNumber); 37 | 38 | // Check if we can reverse-map the source. 39 | if (includeLocation) { 40 | OriginalMapping mapping = source == null 41 | ? null 42 | : source.getSourceMapping(error.getSourceName(), error.getLineNumber(), error.getCharno()); 43 | if (mapping == null) { 44 | boldLine.append(nonMappedPosition); 45 | } else { 46 | sourceName = mapping.getOriginalFile(); 47 | lineNumber = mapping.getLineNumber(); 48 | 49 | b.append(nonMappedPosition); 50 | b.append("\nOriginally at:\n"); 51 | boldLine.append(formatPosition(sourceName, lineNumber)); 52 | } 53 | } 54 | 55 | boldLine.append(severity == BuildContext.SEVERITY_WARNING ? "WARNING" : "ERROR"); 56 | boldLine.append(" - "); 57 | 58 | boldLine.append(error.getDescription()); 59 | 60 | b.append(boldLine); 61 | b.append('\n'); 62 | return b.toString(); 63 | } 64 | 65 | private static String formatPosition(String sourceName, int lineNumber) { 66 | StringBuilder b = new StringBuilder(); 67 | if (sourceName != null) { 68 | b.append(sourceName); 69 | if (lineNumber > 0) { 70 | b.append(':'); 71 | b.append(lineNumber); 72 | } 73 | b.append(": "); 74 | } 75 | return b.toString(); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/common/FileException.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.common; 2 | 3 | import java.util.ArrayList; 4 | 5 | final class FileException extends RuntimeException { 6 | private final Iterable fileErrors; 7 | 8 | public FileException(Iterable fileErrors) { 9 | this.fileErrors = fileErrors != null ? fileErrors : new ArrayList<>(); 10 | } 11 | 12 | public Iterable getFileErrors() { 13 | return fileErrors; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/common/FileMessage.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.common; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import org.sonatype.plexus.build.incremental.BuildContext; 6 | 7 | class FileMessage { 8 | private final Throwable cause; 9 | 10 | private final int column; 11 | 12 | private final File file; 13 | 14 | private final int line; 15 | 16 | private final String message; 17 | 18 | private final int severity; 19 | 20 | public FileMessage(File file, int line, int column, String message, int severity, Throwable cause) { 21 | this.file = file; 22 | this.line = line; 23 | this.column = column; 24 | this.severity = severity; 25 | this.cause = cause; 26 | this.message = message; 27 | } 28 | 29 | public Throwable getCause() { 30 | return cause; 31 | } 32 | 33 | public int getColumn() { 34 | return column; 35 | } 36 | 37 | public File getFile() { 38 | return file; 39 | } 40 | 41 | public int getLine() { 42 | return line; 43 | } 44 | 45 | public String getMessage() { 46 | return message; 47 | } 48 | 49 | public int getSeverity() { 50 | return severity; 51 | } 52 | 53 | public void addTo(BuildContext context) { 54 | if (context == null) { 55 | return; 56 | } 57 | File cFile = null; 58 | try { 59 | cFile = file.getCanonicalFile(); 60 | } catch (IOException e) { 61 | cFile = file; 62 | } 63 | try { 64 | context.addMessage(cFile, line, column, message, severity, cause); 65 | } catch (Exception e) { 66 | // too bad... 67 | e.printStackTrace(); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/common/FileProcessConfig.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.common; 2 | 3 | import com.github.blutorange.maven.plugin.closurecompiler.plugin.SkipMode; 4 | 5 | public final class FileProcessConfig { 6 | private final boolean skipMerge; 7 | private final boolean skipMinify; 8 | private final boolean force; 9 | private final int bufferSize; 10 | private final String lineSeparator; 11 | private final SkipMode skipMode; 12 | private final boolean gzip; 13 | private final boolean allowReplacingInputFiles; 14 | 15 | public FileProcessConfig( 16 | String lineSeparator, 17 | int bufferSize, 18 | boolean force, 19 | boolean skipMerge, 20 | boolean skipMinify, 21 | SkipMode skipMode, 22 | boolean gzip, 23 | boolean allowReplacingInputFiles) { 24 | this.lineSeparator = lineSeparator; 25 | this.bufferSize = bufferSize; 26 | this.force = force; 27 | this.skipMerge = skipMerge; 28 | this.skipMinify = skipMinify; 29 | this.skipMode = skipMode; 30 | this.gzip = gzip; 31 | this.allowReplacingInputFiles = allowReplacingInputFiles; 32 | } 33 | 34 | public boolean isAllowReplacingInputFiles() { 35 | return allowReplacingInputFiles; 36 | } 37 | 38 | public boolean isSkipMerge() { 39 | return skipMerge; 40 | } 41 | 42 | public boolean isSkipMinify() { 43 | return skipMinify; 44 | } 45 | 46 | public boolean isForce() { 47 | return force; 48 | } 49 | 50 | public SkipMode getSkipMode() { 51 | return skipMode; 52 | } 53 | 54 | public boolean isGzip() { 55 | return gzip; 56 | } 57 | 58 | public int getBufferSize() { 59 | return bufferSize; 60 | } 61 | 62 | public String getLineSeparator() { 63 | return lineSeparator; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/common/FileSpecifier.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.common; 2 | 3 | import java.io.File; 4 | import java.util.List; 5 | 6 | public final class FileSpecifier { 7 | private final File baseSourceDir; 8 | private final File baseTargetDir; 9 | private final String sourceDir; 10 | private final String targetDir; 11 | private final List includes; 12 | private final List excludes; 13 | private final String outputFilename; 14 | 15 | public FileSpecifier( 16 | File baseSourceDir, 17 | File baseTargetDir, 18 | String sourceDir, 19 | String targetDir, 20 | List includes, 21 | List excludes, 22 | String outputFilename) { 23 | this.baseSourceDir = baseSourceDir; 24 | this.baseTargetDir = baseTargetDir; 25 | this.sourceDir = sourceDir; 26 | this.targetDir = targetDir; 27 | this.includes = includes; 28 | this.excludes = excludes; 29 | this.outputFilename = outputFilename; 30 | } 31 | 32 | public File getBaseSourceDir() { 33 | return baseSourceDir; 34 | } 35 | 36 | public File getBaseTargetDir() { 37 | return baseTargetDir; 38 | } 39 | 40 | public String getSourceDir() { 41 | return sourceDir; 42 | } 43 | 44 | public String getTargetDir() { 45 | return targetDir; 46 | } 47 | 48 | public List getIncludes() { 49 | return includes; 50 | } 51 | 52 | public List getExcludes() { 53 | return excludes; 54 | } 55 | 56 | public String getOutputFilename() { 57 | return outputFilename; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/common/FileSystemLocationMapping.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.common; 2 | 3 | import com.google.javascript.jscomp.SourceMap.LocationMapping; 4 | import java.io.File; 5 | import org.apache.commons.io.FilenameUtils; 6 | import org.apache.commons.lang3.StringUtils; 7 | import org.apache.maven.plugin.logging.Log; 8 | 9 | /** Makes the source file relative to the location of the source map. The paths are taken from the file system. */ 10 | final class FileSystemLocationMapping implements LocationMapping { 11 | private final File baseDirForSourceFiles; 12 | private final File sourceMapDir; 13 | private final Log log; 14 | private boolean transpilationDone; 15 | 16 | public FileSystemLocationMapping(Log log, File baseDirForSourceFiles, File sourceMapFile) { 17 | this.log = log; 18 | this.baseDirForSourceFiles = baseDirForSourceFiles; 19 | this.sourceMapDir = sourceMapFile.getParentFile(); 20 | } 21 | 22 | @Override 23 | public String map(String location) { 24 | final String mapped; 25 | if (transpilationDone) { 26 | // This is the source file relative to the source map 27 | mapped = location; 28 | } else if (StringUtils.startsWith(StringUtils.trim(location), "[")) { 29 | // Internal files from closure compiler, such as "[synthetic:base]" 30 | mapped = location; 31 | } else { 32 | final File file = new File(baseDirForSourceFiles, location); 33 | mapped = FilenameUtils.separatorsToUnix(FileHelper.relativizePath(sourceMapDir, file)); 34 | } 35 | log.debug("Source map: mapping location [" + location + "] to [" + mapped + "]"); 36 | return mapped; 37 | } 38 | 39 | public void setTranspilationDone(boolean transpilationDone) { 40 | this.transpilationDone = transpilationDone; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/common/FilenameInterpolator.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.common; 2 | 3 | import java.io.File; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | import org.apache.commons.io.FilenameUtils; 7 | import org.apache.commons.text.StringSubstitutor; 8 | 9 | final class FilenameInterpolator { 10 | private final String pattern; 11 | private final String prefix; 12 | private final String suffix; 13 | private final char escapeChar; 14 | 15 | public FilenameInterpolator(String pattern) { 16 | this(pattern, "#{", "}", '#'); 17 | } 18 | 19 | public FilenameInterpolator(String pattern, String prefix, String suffix, char escapeChar) { 20 | this.pattern = pattern; 21 | this.prefix = prefix; 22 | this.suffix = suffix; 23 | this.escapeChar = escapeChar; 24 | } 25 | 26 | public File interpolate(File inputFile, File inputBaseDir, File targetDirectory) { 27 | return interpolate(inputFile, inputBaseDir, targetDirectory, null); 28 | } 29 | 30 | public File interpolate( 31 | File inputFile, File inputBaseDir, File targetDirectory, Map additionalData) { 32 | final var interpolatedFilename = interpolateRelative(inputFile, inputBaseDir, additionalData); 33 | return new File(targetDirectory, interpolatedFilename); 34 | } 35 | 36 | public String interpolateRelative(File inputFile, File inputBaseDir) { 37 | return interpolateRelative(inputFile, inputBaseDir, null); 38 | } 39 | 40 | public String interpolateRelative(File inputFile, File inputBaseDir, Map additionalData) { 41 | final var inputFilename = inputFile.getName(); 42 | final var data = new HashMap(); 43 | data.put("filename", inputFilename); 44 | data.put("extension", FilenameUtils.getExtension(inputFilename)); 45 | data.put("basename", FilenameUtils.getBaseName(inputFilename)); 46 | data.put("path", FileHelper.relativizePath(inputBaseDir, inputFile.getParentFile())); 47 | if (additionalData != null) { 48 | data.putAll(additionalData); 49 | } 50 | final var stringSubstitutor = new StringSubstitutor(data, prefix, suffix, escapeChar); 51 | return stringSubstitutor.replace(pattern); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/common/LogWrapper.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.common; 2 | 3 | import com.github.blutorange.maven.plugin.closurecompiler.plugin.LogLevel; 4 | import org.apache.maven.plugin.logging.Log; 5 | 6 | /** 7 | * A wrapper for a logger that allows overwriting the log level. 8 | * 9 | * @author madgaksha 10 | */ 11 | public final class LogWrapper implements Log { 12 | private final Log wrapped; 13 | private final LogLevel level; 14 | 15 | /** 16 | * @param log Logger to wrap. 17 | * @param level Level to override the default log level of the wrapped logger. If null, do not 18 | * overwrite the log level. 19 | */ 20 | public LogWrapper(Log log, LogLevel level) { 21 | this.wrapped = log; 22 | this.level = level; 23 | } 24 | 25 | @Override 26 | public void debug(CharSequence content) { 27 | if (isDebugEnabled()) { 28 | wrapped.debug(content); 29 | } 30 | } 31 | 32 | @Override 33 | public void debug(CharSequence content, Throwable error) { 34 | if (isDebugEnabled()) { 35 | wrapped.debug(content, error); 36 | } 37 | } 38 | 39 | @Override 40 | public void debug(Throwable error) { 41 | if (isDebugEnabled()) { 42 | wrapped.debug(error); 43 | } 44 | } 45 | 46 | @Override 47 | public void error(CharSequence content) { 48 | if (isErrorEnabled()) { 49 | wrapped.error(content); 50 | } 51 | } 52 | 53 | @Override 54 | public void error(CharSequence content, Throwable error) { 55 | if (isErrorEnabled()) { 56 | wrapped.error(content, error); 57 | } 58 | } 59 | 60 | @Override 61 | public void error(Throwable error) { 62 | if (isErrorEnabled()) { 63 | wrapped.error(error); 64 | } 65 | } 66 | 67 | @Override 68 | public void info(CharSequence content) { 69 | if (isInfoEnabled()) { 70 | wrapped.info(content); 71 | } 72 | } 73 | 74 | @Override 75 | public void info(CharSequence content, Throwable error) { 76 | if (isInfoEnabled()) { 77 | wrapped.info(content, error); 78 | } 79 | } 80 | 81 | @Override 82 | public void info(Throwable error) { 83 | if (isInfoEnabled()) { 84 | wrapped.info(error); 85 | } 86 | } 87 | 88 | @Override 89 | public boolean isDebugEnabled() { 90 | return level == null ? wrapped.isDebugEnabled() : level.isDebugEnabled(); 91 | } 92 | 93 | @Override 94 | public boolean isErrorEnabled() { 95 | return level == null ? wrapped.isErrorEnabled() : level.isErrorEnabled(); 96 | } 97 | 98 | @Override 99 | public boolean isInfoEnabled() { 100 | return level == null ? wrapped.isInfoEnabled() : level.isInfoEnabled(); 101 | } 102 | 103 | @Override 104 | public boolean isWarnEnabled() { 105 | return level == null ? wrapped.isWarnEnabled() : level.isWarnEnabled(); 106 | } 107 | 108 | @Override 109 | public void warn(CharSequence content) { 110 | if (isWarnEnabled()) { 111 | wrapped.warn(content); 112 | } 113 | } 114 | 115 | @Override 116 | public void warn(CharSequence content, Throwable error) { 117 | if (isWarnEnabled()) { 118 | wrapped.warn(content, error); 119 | } 120 | } 121 | 122 | @Override 123 | public void warn(Throwable error) { 124 | if (isWarnEnabled()) { 125 | wrapped.warn(error); 126 | } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/common/ProcessingResult.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.common; 2 | 3 | import java.io.File; 4 | 5 | public class ProcessingResult { 6 | private final boolean wasSkipped; 7 | private final File output; 8 | 9 | public ProcessingResult(Builder builder) { 10 | this.wasSkipped = builder.wasSkipped; 11 | this.output = builder.output; 12 | } 13 | 14 | public static Builder skipped(File file) { 15 | final var builder = new ProcessingResult.Builder(); 16 | builder.wasSkipped = true; 17 | builder.output = file; 18 | return builder; 19 | } 20 | 21 | public static Builder success(File file) { 22 | final var builder = new ProcessingResult.Builder(); 23 | builder.output = file; 24 | return builder; 25 | } 26 | 27 | public boolean isWasSkipped() { 28 | return wasSkipped; 29 | } 30 | 31 | public File getOutput() { 32 | return output; 33 | } 34 | 35 | public static final class Builder { 36 | private boolean wasSkipped; 37 | private File output; 38 | 39 | public ProcessingResult build() { 40 | return new ProcessingResult(this); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/common/TextFileModification.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.common; 2 | 3 | final class TextFileModification { 4 | private final int startPosition; 5 | private final int endPosition; 6 | private final String replacement; 7 | 8 | public TextFileModification(int startPosition, int endPosition, String replacement) { 9 | this.startPosition = startPosition; 10 | this.endPosition = endPosition; 11 | this.replacement = replacement; 12 | } 13 | 14 | public String getReplacement() { 15 | return replacement; 16 | } 17 | 18 | public int getStartPosition() { 19 | return startPosition; 20 | } 21 | 22 | public int getEndPosition() { 23 | return endPosition; 24 | } 25 | 26 | public TextFileModification withOffset(int offset) { 27 | return new TextFileModification(startPosition + offset, endPosition + offset, replacement); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/common/TextFileModifications.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.common; 2 | 3 | import static java.util.Comparator.comparing; 4 | import static java.util.stream.Collectors.toList; 5 | import static org.apache.commons.lang3.StringUtils.substring; 6 | 7 | import java.io.File; 8 | import java.io.IOException; 9 | import java.nio.charset.Charset; 10 | import java.util.List; 11 | import java.util.Objects; 12 | import org.apache.commons.io.FileUtils; 13 | 14 | final class TextFileModifications { 15 | public static boolean applyAndWrite(File file, Charset encoding, List modifications) 16 | throws IOException { 17 | final var textContent = FileUtils.readFileToString(file, encoding); 18 | final var modifiedContent = apply(textContent, modifications); 19 | final var hasChanges = !Objects.equals(textContent, modifiedContent); 20 | if (hasChanges) { 21 | FileUtils.writeStringToFile(file, modifiedContent, encoding); 22 | } 23 | return hasChanges; 24 | } 25 | 26 | public static String apply(String textContent, List modifications) { 27 | final var sortedModifications = modifications.stream() 28 | .sorted(comparing(TextFileModification::getStartPosition).reversed()) 29 | .collect(toList()); 30 | for (final var modification : sortedModifications) { 31 | textContent = applyModification(textContent, modification); 32 | } 33 | return textContent; 34 | } 35 | 36 | private static String applyModification(String content, TextFileModification modification) { 37 | return substring(content, 0, modification.getStartPosition()) 38 | + modification.getReplacement() 39 | + substring(content, modification.getEndPosition()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/plugin/ClosureSourceMapLocationMapping.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.plugin; 2 | 3 | /** 4 | * Key-values pairs used by the closureSourceMapLocationMappings option of the minify plugin. Each pair 5 | * defines a prefix mapping from the file system path to the web server path. 6 | */ 7 | public class ClosureSourceMapLocationMapping { 8 | @SuppressWarnings("unused") 9 | private String name; 10 | 11 | @SuppressWarnings("unused") 12 | private String value; 13 | 14 | public String getName() { 15 | return this.name; 16 | } 17 | 18 | public String getValue() { 19 | return this.value; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/plugin/DependencyModeFlag.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.plugin; 2 | 3 | import com.google.javascript.jscomp.DependencyOptions.DependencyMode; 4 | 5 | public enum DependencyModeFlag { 6 | NONE, 7 | SORT_ONLY, 8 | PRUNE_LEGACY, 9 | PRUNE, 10 | LOOSE, 11 | STRICT; 12 | 13 | public static DependencyMode toDependencyMode(DependencyModeFlag flag) { 14 | if (flag == null) { 15 | return null; 16 | } 17 | switch (flag) { 18 | case NONE: 19 | return DependencyMode.NONE; 20 | case SORT_ONLY: 21 | return DependencyMode.SORT_ONLY; 22 | case PRUNE_LEGACY: 23 | case LOOSE: 24 | return DependencyMode.PRUNE_LEGACY; 25 | case PRUNE: 26 | case STRICT: 27 | return DependencyMode.PRUNE; 28 | } 29 | throw new AssertionError("Bad DependencyModeFlag"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/plugin/FileSet.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.plugin; 2 | 3 | import com.github.blutorange.maven.plugin.closurecompiler.common.FileHelper; 4 | import java.io.File; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | /** 9 | * A file set consisting of includes and excludes. The includes are evaluated first, then the excludes are subtracted. 10 | */ 11 | public class FileSet { 12 | @SuppressWarnings("unused") 13 | private List includes; 14 | 15 | @SuppressWarnings("unused") 16 | private List excludes; 17 | 18 | /** 19 | * Gets the list of include patterns. Each pattern may use wildcards. 20 | * 21 | * @return Include patterns for scanning for matching files. 22 | */ 23 | public List getIncludes() { 24 | if (includes == null) { 25 | includes = new ArrayList<>(); 26 | } 27 | return includes; 28 | } 29 | 30 | /** 31 | * Gets the list of exclude patterns. Each pattern may use wildcards. The excludes are applied after the includes. 32 | * 33 | * @return Exclude patterns for scanning for matching files. 34 | */ 35 | public List getExcludes() { 36 | if (excludes == null) { 37 | excludes = new ArrayList<>(); 38 | } 39 | return excludes; 40 | } 41 | 42 | /** 43 | * Gets all files in the given base directory that match the includes and excludes patterns. 44 | * 45 | * @param baseDir Base directory to scan for files. 46 | * @return All matching files. 47 | */ 48 | public List getFiles(File baseDir) { 49 | return FileHelper.getIncludedFiles(baseDir, getIncludes(), getExcludes()); 50 | } 51 | 52 | @Override 53 | public String toString() { 54 | return String.format("[includes=%s,excludes=%s]", getIncludes(), getExcludes()); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/plugin/HtmlUpdateConfigImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.plugin; 2 | 3 | import com.github.blutorange.maven.plugin.closurecompiler.shared.HtmlUpdateConfig; 4 | import java.io.File; 5 | import java.util.List; 6 | 7 | final class HtmlUpdateConfigImpl implements HtmlUpdateConfig { 8 | private final List htmlUpdates; 9 | private final File htmlDir; 10 | private final File htmlRoot; 11 | private final File htmlScriptRoot; 12 | private final String htmlSourcePath; 13 | private final Boolean htmlUsePhysicalRoot; 14 | 15 | public HtmlUpdateConfigImpl( 16 | List htmlUpdates, 17 | File htmlDir, 18 | File htmlRoot, 19 | File htmlScriptRoot, 20 | String htmlSourcePath, 21 | Boolean htmlUsePhysicalRoot) { 22 | this.htmlUpdates = htmlUpdates != null ? htmlUpdates : List.of(); 23 | this.htmlDir = htmlDir; 24 | this.htmlRoot = htmlRoot; 25 | this.htmlScriptRoot = htmlScriptRoot; 26 | this.htmlSourcePath = htmlSourcePath; 27 | this.htmlUsePhysicalRoot = htmlUsePhysicalRoot; 28 | } 29 | 30 | @Override 31 | public Boolean isHtmlUsePhysicalRoot() { 32 | return htmlUsePhysicalRoot; 33 | } 34 | 35 | @Override 36 | public String getHtmlSourcePath() { 37 | return htmlSourcePath; 38 | } 39 | 40 | @Override 41 | public List getHtmlUpdates() { 42 | return htmlUpdates; 43 | } 44 | 45 | @Override 46 | public File getHtmlDir() { 47 | return htmlDir; 48 | } 49 | 50 | @Override 51 | public File getHtmlRoot() { 52 | return htmlRoot; 53 | } 54 | 55 | @Override 56 | public File getHtmlScriptRoot() { 57 | return htmlScriptRoot; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/plugin/LogLevel.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.plugin; 2 | 3 | public enum LogLevel { 4 | all(0), 5 | debug(1), 6 | info(2), 7 | warn(3), 8 | error(4), 9 | none(5); 10 | private final int order; 11 | 12 | LogLevel(int order) { 13 | this.order = order; 14 | } 15 | 16 | public boolean isErrorEnabled() { 17 | return order >= error.order; 18 | } 19 | 20 | public boolean isWarnEnabled() { 21 | return order >= warn.order; 22 | } 23 | 24 | public boolean isInfoEnabled() { 25 | return order >= info.order; 26 | } 27 | 28 | public boolean isDebugEnabled() { 29 | return order >= debug.order; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/plugin/MojoMetaImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.plugin; 2 | 3 | import com.github.blutorange.maven.plugin.closurecompiler.shared.MojoMetadata; 4 | import java.nio.charset.Charset; 5 | import org.apache.maven.plugin.logging.Log; 6 | import org.apache.maven.project.MavenProject; 7 | import org.sonatype.plexus.build.incremental.BuildContext; 8 | 9 | final class MojoMetaImpl implements MojoMetadata { 10 | 11 | private final MavenProject project; 12 | private final Log log; 13 | private final Charset encoding; 14 | private final BuildContext buildContext; 15 | 16 | public MojoMetaImpl(MavenProject project, Log log, String encoding, BuildContext buildContext) { 17 | this.project = project; 18 | this.log = log; 19 | this.encoding = Charset.forName(encoding); 20 | this.buildContext = buildContext; 21 | } 22 | 23 | @Override 24 | public MavenProject getProject() { 25 | return project; 26 | } 27 | 28 | @Override 29 | public Log getLog() { 30 | return log; 31 | } 32 | 33 | @Override 34 | public Charset getEncoding() { 35 | return encoding; 36 | } 37 | 38 | @Override 39 | public BuildContext getBuildContext() { 40 | return buildContext; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/plugin/SkipMode.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.plugin; 2 | 3 | /** Enumeration for the possible options of whether processing a file should be skipped. */ 4 | public enum SkipMode { 5 | /** Do not recreate an output file when it is newer (more recently modified) that all input files. */ 6 | NEWER, 7 | /** Do not recreate an output file when it exists already, irrespective of the modification date. */ 8 | EXISTS; 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/plugin/SourceMapOutputType.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.plugin; 2 | 3 | public enum SourceMapOutputType { 4 | /** Just create a source map file named *.map. */ 5 | file(true), 6 | /** Inline the content of the source map in the minified file. */ 7 | inline(false), 8 | /** Create a source map file *.map and add a reference to it in the minified file. */ 9 | reference(true); 10 | 11 | private final boolean createFile; 12 | 13 | SourceMapOutputType(boolean createFile) { 14 | this.createFile = createFile; 15 | } 16 | 17 | public boolean isCreateFile() { 18 | return createFile; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/shared/HtmlUpdateConfig.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.shared; 2 | 3 | import com.github.blutorange.maven.plugin.closurecompiler.plugin.HtmlUpdate; 4 | import java.io.File; 5 | import java.util.List; 6 | 7 | public interface HtmlUpdateConfig { 8 | Boolean isHtmlUsePhysicalRoot(); 9 | 10 | String getHtmlSourcePath(); 11 | 12 | List getHtmlUpdates(); 13 | 14 | File getHtmlDir(); 15 | 16 | File getHtmlRoot(); 17 | 18 | File getHtmlScriptRoot(); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/blutorange/maven/plugin/closurecompiler/shared/MojoMetadata.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.shared; 2 | 3 | import java.nio.charset.Charset; 4 | import org.apache.maven.plugin.logging.Log; 5 | import org.apache.maven.project.MavenProject; 6 | import org.sonatype.plexus.build.incremental.BuildContext; 7 | 8 | public interface MojoMetadata { 9 | MavenProject getProject(); 10 | 11 | Log getLog(); 12 | 13 | Charset getEncoding(); 14 | 15 | BuildContext getBuildContext(); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | minify 7 | 8 | 9 | 10 | 11 | true 12 | true 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/site/apt/examples/basic.apt: -------------------------------------------------------------------------------- 1 | ------ 2 | Basic Configuration 3 | ------ 4 | Samuel Santos 5 | Andre Wachsmuth 6 | ------ 7 | 2018-09-08 8 | ------ 9 | 10 | Basic Configuration 11 | 12 | The only requirement for Closure Compiler Maven Plugin to run is to have source files to process. 13 | 14 | By default, all source files are minified and merged into one file. You change this behavior with the options {{{../minify-mojo.html#skipMerge}skipMerge}} and {{{../minify-mojo.html#skipMinify}skipMinify}}. 15 | 16 | Also, the name of the output file defaults to <<>>. To change this, use the option {{{../minify-mojo.html#outputFilename}outputFilename}}. 17 | 18 | +---+ 19 | 20 | 21 | 22 | 23 | 24 | 25 | com.github.blutorange 26 | closure-compiler-maven-plugin 27 | ${closure-compiler-maven-plugin.version} 28 | 29 | 30 | default-minify 31 | 32 | 33 | 34 | file-1.js 35 | 36 | file-n.js 37 | 38 | 39 | 40 | minify 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | +---+ 51 | -------------------------------------------------------------------------------- /src/site/apt/examples/exclude.apt: -------------------------------------------------------------------------------- 1 | ------ 2 | Exclude source files from WAR package 3 | ------ 4 | Samuel Santos 5 | Andre Wachsmuth 6 | ------ 7 | 2018-10-08 8 | ------ 9 | 10 | Exclude source files from WAR package 11 | 12 | Sometimes we need to exclude the original source files from the final WAR package. 13 | 14 | A possible scenario is when you do not want to make them publicly available via your site for security reasons, or simply only want to include only the minified file in the resulting war. 15 | 16 | The method I recommend is to place your source files outside the <<>> directory so they won't get included automatically. For example, you could place them in "src/main/js". Then configure this plugin to output your files to <<>> and include that in the WAR file: 17 | 18 | +---+ 19 | 20 | 21 | 22 | ${project.basedir}/src/main/resources 23 | 24 | 25 | ${project.build.directory}/generated-resources 26 | 27 | 28 | 29 | +---+ 30 | 31 | In case that is not an options, the example below illustrates how to configure Maven WAR Plugin to exclude the undesired source files from the final WAR package. 32 | 33 | You should also consider creating separate directories for source files and generated files, this makes the configration clearer. 34 | 35 | +---+ 36 | 37 | 38 | 39 | 40 | 41 | 42 | org.apache.maven.plugins 43 | maven-war-plugin 44 | 45 | **/file-1.css,...,**/file-n.css,**/file-1.js,...,**/file-n.js 46 | 47 | 48 | 49 | 50 | com.github.blutorange 51 | closure-compiler-maven-plugin 52 | ${closure-compiler-maven-plugin.version} 53 | 54 | 55 | default-minify 56 | 57 | 58 | file-1.js 59 | 60 | file-n.js 61 | 62 | 63 | 64 | minify 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | +---+ 75 | -------------------------------------------------------------------------------- /src/site/apt/examples/m2e.apt: -------------------------------------------------------------------------------- 1 | ------ 2 | m2e 3 | ------ 4 | Andre Wachsmuth 5 | ------ 6 | 2018-09-08 7 | ------ 8 | 9 | Eclipse m2e integration 10 | 11 | This plugin supports Eclipse {{{http://www.eclipse.org/m2e/}m2e}} maven integration. By default, it runs on incremental builds. This means that everytime you change 12 | and save a relevant source JavaScript file, the minified / bundled files are recreated. The plugin checks whether a relevant source 13 | file was changed and won't run if you just edited a Java file etc. 14 | 15 | To turn of this behavior and have the plugin run only when doing a manual full build, use the skipRunOnIncremental option: 16 | 17 | +---+ 18 | 19 | 20 | 21 | 22 | 23 | 24 | com.github.blutorange 25 | closure-compiler-maven-plugin 26 | ${closure-compiler-maven-plugin.version} 27 | 28 | 29 | true 30 | 31 | 32 | 33 | 34 | 35 | 36 | +---+ 37 | 38 | 39 | Please note that technically, the plugin is still executed on every incremental build cycle, 40 | but skips any processing and should not take any time. If you need to turn off the plugin 41 | completely, use the lifecycle-plugin: 42 | 43 | +---+ 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.eclipse.m2e 53 | lifecycle-mapping 54 | 1.0.0 55 | 56 | 57 | 58 | 59 | 60 | com.github.blutorange 61 | closure-compiler-maven-plugin 62 | [2.0.0,) 63 | 64 | minify 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | com.github.blutorange 78 | closure-compiler-maven-plugin 79 | ${closure-compiler-maven-plugin.version} 80 | 81 | 82 | default-minify 83 | 84 | 85 | myfiles.js 86 | 87 | 88 | 89 | minify 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | +---+ 100 | -------------------------------------------------------------------------------- /src/site/apt/examples/patterns.apt: -------------------------------------------------------------------------------- 1 | ------ 2 | Using include/exclude patterns 3 | ------ 4 | Samuel Santos 5 | Andre Wachsmuth 6 | ------ 7 | 2018-10-08 8 | ------ 9 | 10 | Using include/exclude patterns 11 | 12 | This plugin supports include/exclude patterns. When bundling into one file, the order in which the source files were specified is preserved. Specifically: 13 | 14 | * For each <<>>, find all files matching the wildcard pattern (observing the <<>>). 15 | 16 | * For each <<>>, sort the matching files alphabetically. 17 | 18 | * Then add the matching files for each <<>> in the order the <<>> were specified. 19 | 20 | +---+ 21 | 22 | 23 | 24 | 25 | 26 | 27 | com.github.blutorange 28 | closure-compiler-maven-plugin 29 | 8.0 30 | 31 | 32 | default-minify 33 | 34 | 35 | 36 | **/*Prerequisites.js 37 | **/*Custom.js 38 | 39 | 40 | **/*.min.js 41 | 42 | 43 | 44 | minify 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | +---+ 55 | -------------------------------------------------------------------------------- /src/site/apt/examples/watch.apt: -------------------------------------------------------------------------------- 1 | ------ 2 | Watch 3 | ------ 4 | Andre Wachsmuth 5 | ------ 6 | 2018-09-08 7 | ------ 8 | 9 | Watching for file changes 10 | 11 | When working on a project, it helps to have your files built automatically when you change a source file. There may be subtle differences 12 | between the source files and the merged, transpiled and minified output. To detect possible bugs and errors as soon as possible, I recommend 13 | you develop with the built JavaScript files. Closure compiler itself does not offer a watch mode. This leaves you with two options: 14 | 15 | * If you are using Eclipse, see {{{./m2e.html}m2e maven integration}}. 16 | 17 | * Outside of eclipse, you can use a third-party maven plugin to watch for file changes and trigger the execution of this plugin. See below for an example. 18 | 19 | +---+ 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | com.fizzed 29 | fizzed-watcher-maven-plugin 30 | 1.0.6 31 | 32 | 33 | 34 | 35 | ${basedir}/path/to/your/js/files 36 | 37 | 38 | true 39 | 40 | 41 | generate-resources 42 | 43 | 44 | 45 | development 46 | 47 | 48 | 49 | 50 | 51 | com.github.blutorange 52 | closure-compiler-maven-plugin 53 | ${closure-compiler-maven-plugin.version} 54 | 55 | 56 | default-minify 57 | 58 | 59 | myfiles.js 60 | 61 | 62 | 63 | minify 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | +---+ 74 | -------------------------------------------------------------------------------- /src/site/apt/index.apt: -------------------------------------------------------------------------------- 1 | ------ 2 | Introduction 3 | ------ 4 | Samuel Santos 5 | Andre Wachsmuth 6 | ------ 7 | 2018-10-08 8 | ------ 9 | 10 | Closure Compiler Maven Plugin 11 | 12 | This plugin combines and minimizes JavaScript files. 13 | 14 | As the name implies, it is a wrapper around {{{https://developers.google.com/closure/compiler/}Google Closure Compiler}}. 15 | 16 | * Goals Overview 17 | 18 | * {{{./minify-mojo.html}minify:minify}} combine and minimize JavaScript files. 19 | 20 | * Usage 21 | 22 | General instructions on how to use the Closure Compiler Maven Plugin can be found on the {{{./usage.html}usage page}}. Some more specific use cases are described in the examples given below. 23 | 24 | f you are missing an option from Closure Compiler, feel free to create an issue. There are many, but most of them are not hard too add. 25 | 26 | If you feel like the plugin is missing a feature or has a defect, you can fill a feature request or bug report in the {{{./issue-management.html}issue tracker}}. When creating a new issue, please provide a comprehensive description of your concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason, entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. Of course, patches are welcome, too. Contributors can check out the project from the {{{./scm.html}source repository}}. 27 | 28 | 29 | * Examples 30 | 31 | To provide you with better understanding of some usages of the Minify Maven Plugin, you can take a look into the following examples: 32 | 33 | * {{{./examples/basic.html}Basic Configuration}} 34 | 35 | * {{{./examples/patterns.html}Using include/exclude patterns}} 36 | 37 | * {{{./examples/bundle.html}Bundle Configuration}} 38 | 39 | * {{{./examples/exclude.html}Exclude source files from WAR package}} 40 | 41 | * {{{./examples/m2e.html}Eclipse m2e maven integration}} 42 | 43 | * {{{./examples/watch.html}Watching for file changes}} 44 | 45 | * {{{./examples/htmlUpdate.html}Updating HTML files}} 46 | -------------------------------------------------------------------------------- /src/site/apt/usage.apt: -------------------------------------------------------------------------------- 1 | ------ 2 | Usage 3 | ------ 4 | Samuel Santos 5 | Andre Wachsmuth 6 | ------ 7 | 2018-10-08 8 | ------ 9 | 10 | Usage 11 | 12 | This document is intended to provide instructions for using the Closure Compiler Maven Plugin.\ 13 | In order for this discussion to be useful, it's critical to cover two topics: 14 | 15 | [[1]] Configuring your project's <<>> to run the plugin during the project's build cycle 16 | 17 | [[2]] Invoking the plugin from the command-line 18 | 19 | * Configure Minify Maven Plugin 20 | 21 | By tying the goals of the plugin to a phase in the build cycle, the specified goals will run each time that phase of the build cycle is executed. Doing this can make it easier to add the plugin to your project, because it eliminates the need to run the plugin standalone. 22 | 23 | To bind the minify goal of the Minify Maven Plugin to a phase in the build cycle, you will need to add the <<>> tag with the <<>> set to <<>>. Optionally, you can bind the plugin to a different build phase by using the <<>> option. For instance, using <<>> in the <<>> option will force the minify goal to run each time this phase of the build cycle occurs. 24 | 25 | For a complete list of the available configuration options see {{{./minify-mojo.html}minify:minify}} goal overview page. 26 | 27 | ** Merge order 28 | 29 | Applies when input JS files are merged and minified into a single output file: 30 | 31 | [[1]] For each include (input file) defined in <<>>, the list of matching files is created. 32 | 33 | [[2]] The matching files for each <<>> are sorted alphabetically. 34 | 35 | [[3]] Matching files from different <<>>'s are added in the order as specified. 36 | 37 | See also {{{./examples/patterns.html}Using include/exclude patterns}}. 38 | 39 | +---+ 40 | 41 | 42 | 43 | 44 | 45 | 46 | com.github.blutorange 47 | closure-compiler-maven-plugin 48 | ${closure-compiler-maven-plugin.version} 49 | 50 | 51 | default-minify 52 | package 53 | 54 | 55 | 56 | UTF-8 57 | ${basedir}/src/main/webapp 58 | ${project.build.directory}/${project.build.finalName} 59 | js 60 | js 61 | 62 | 63 | 64 | file-1.js 65 | 66 | file-n.js 67 | 68 | script.js 69 | 70 | 71 | 72 | 73 | minify 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | +---+ 85 | 86 | * Invoke from the command-line 87 | 88 | Create the project archive containing the new files. 89 | 90 | +---+ 91 | mvn package 92 | +---+ 93 | -------------------------------------------------------------------------------- /src/site/fml/faq.fml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | How is this related to Closure Compiler CLI? 6 | 7 |

This is a maven plugin that allows you to run closure compiler on your project sources when building your project.

. 8 |

It uses the Java API of closure compiler, but I try to stay as close to the options from the Closure Compiler CLI application.

9 |
10 |
11 | 12 | Can you add a new option from Closure Compiler? 13 | 14 |

Sure, no problem. Open a new issue

. 15 |

But please not that I try not to expose any internal options not offered by the Closure Compiler CLI application.

16 |
17 |
18 | 19 | Is it possible to create multiple bundles? 20 | 21 |

Yes! Use multiple <execution> tags with different final names.

22 |

Note that execution id's have to be unique among all executions of a single plugin within a POM.

23 |
24 |
25 | 26 | Where can I find a complete list of the available options to configure Closure Compiler Maven Plugin? 27 | 28 |

See minify:minify goal overview page.

29 |
30 |
31 | 32 | Does Closure Compiler Maven Plugin support watching for file changes? 33 | 34 |

Google Closure Compiler itself does not sport a watch mode, but see the example for watching for file changes

. 35 |
36 |
37 | 38 | Does Closure Compiler Maven Plugin integrate with Eclipse m2e? 39 | 40 |

Yes

41 |
42 |
43 | 44 | Which JavaScript compressor engines does Closure Compiler Maven Plugin support? 45 | 46 |

As the name implies, it uses Google Closure Compiler

. 47 |
48 |
49 |
50 |
51 | -------------------------------------------------------------------------------- /src/site/markdown/examples/bundle.md: -------------------------------------------------------------------------------- 1 | # Bundle Configuration 2 | 3 | **Deprecated** 4 | 5 | You can simply use multiple `` in the plugin configuration. If you have a use-case for bundles, consider 6 | [opening an issue and discuss it](../issue-management.html). 7 | 8 | --- 9 | 10 | You can optionally specify the source files to process via an external configuration file. When a `bundleConfiguration` 11 | is defined, it overrides `includes` of the [Basic Configuration](../examples/basic.html). 12 | 13 | ```xml 14 | 15 | 16 | 17 | 18 | 19 | 20 | com.github.blutorange 21 | closure-compiler-maven-plugin 22 | ${closure-compiler-maven-plugin.version} 23 | 24 | 25 | bundle-minify 26 | 27 | src/minify/static-bundles.json 28 | 29 | 30 | minify 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | ``` 41 | 42 | # Configuration Format 43 | 44 | Bundles are defined in JSON format. 45 | 46 | ```json 47 | { 48 | "bundles": [ 49 | { 50 | "name": "static-combined.js", 51 | "includes": [ 52 | "blutorange.js", 53 | "subdir/pearce-kelly.js" 54 | ], 55 | "excludes": [] 56 | } 57 | ] 58 | } 59 | ``` -------------------------------------------------------------------------------- /src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | org.apache.maven.skins 40 | maven-fluido-skin 41 | 2.0.0-M10 42 | 43 | 44 | 45 | 46 | span3 47 | span9 48 | 49 | blutorange/closure-compiler-maven-plugin 50 | right 51 | red 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/test/java/com/github/blutorange/maven/plugin/closurecompiler/test/NoOpOutputStream.java: -------------------------------------------------------------------------------- 1 | package com.github.blutorange.maven.plugin.closurecompiler.test; 2 | 3 | import java.io.IOException; 4 | import java.io.OutputStream; 5 | 6 | public class NoOpOutputStream extends OutputStream { 7 | @Override 8 | public void write(int b) throws IOException {} 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%kvp- %msg%n 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/test/resources/projects/allowdynamicimport/expected/dynamic-imports-extern.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | async function onMoreClicked(a) { 3 | ({enableAwesomeFeature:a} = await import("./awesome-feature.js")); 4 | a(); 5 | } 6 | document.getElementById("loadMore").addEventListener(a => onMoreClicked(a)); 7 | export{}; -------------------------------------------------------------------------------- /src/test/resources/projects/allowdynamicimport/expected/dynamic-imports-true.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | async function onMoreClicked(a) { 3 | ({enableAwesomeFeature:a} = await Promise.resolve(module$import)); 4 | a(); 5 | } 6 | document.getElementById("loadMore").addEventListener(a => onMoreClicked(a)); 7 | function enableAwesomeFeature$$module$import() { 8 | console.log("The awesome feature shall now be enabled."); 9 | } 10 | var module$import = {}; 11 | module$import.enableAwesomeFeature = enableAwesomeFeature$$module$import; 12 | 13 | -------------------------------------------------------------------------------- /src/test/resources/projects/allowdynamicimport/test/extern/dynamic-import-extern.js: -------------------------------------------------------------------------------- 1 | async function onMoreClicked(event) { 2 | const module = "./awesome-feature.js"; 3 | const { enableAwesomeFeature } = await import(module); 4 | enableAwesomeFeature(); 5 | } 6 | 7 | document.getElementById("loadMore").addEventListener(e => onMoreClicked(e)); -------------------------------------------------------------------------------- /src/test/resources/projects/allowdynamicimport/test/false/dynamic-import-false.js: -------------------------------------------------------------------------------- 1 | import { enableAwesomeFeature } from "./import.js"; 2 | 3 | async function onMoreClicked(event) { 4 | enableAwesomeFeature(); 5 | } 6 | 7 | document.getElementById("loadMore").addEventListener(e => onMoreClicked(e)); -------------------------------------------------------------------------------- /src/test/resources/projects/allowdynamicimport/test/false/import.js: -------------------------------------------------------------------------------- 1 | export function enableAwesomeFeature() { 2 | console.log("The awesome feature shall now be enabled."); 3 | } -------------------------------------------------------------------------------- /src/test/resources/projects/allowdynamicimport/test/true/dynamic-import-true.js: -------------------------------------------------------------------------------- 1 | async function onMoreClicked(event) { 2 | const { enableAwesomeFeature } = await import("./import.js"); 3 | enableAwesomeFeature(); 4 | } 5 | 6 | document.getElementById("loadMore").addEventListener(e => onMoreClicked(e)); -------------------------------------------------------------------------------- /src/test/resources/projects/allowdynamicimport/test/true/import.js: -------------------------------------------------------------------------------- 1 | export function enableAwesomeFeature() { 2 | console.log("The awesome feature shall now be enabled."); 3 | } -------------------------------------------------------------------------------- /src/test/resources/projects/assumeFunctionWrapper/expected/assume-function-wrapper-false.js: -------------------------------------------------------------------------------- 1 | 'use strict';var longVariable=9;class Foo{init(){return longVariable+6}exit(){return longVariable-6}}console.log(typeof new Foo);console.log(x); 2 | 3 | -------------------------------------------------------------------------------- /src/test/resources/projects/assumeFunctionWrapper/expected/assume-function-wrapper-true.js: -------------------------------------------------------------------------------- 1 | 'use strict';class a{init(){return 15}exit(){return 3}}console.log(typeof new a);console.log(x); 2 | 3 | -------------------------------------------------------------------------------- /src/test/resources/projects/assumeFunctionWrapper/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | com.github.blutorange 8 | closure-compiler-maven-plugin-test-assumefunctionwrapper 9 | 1.0-SNAPSHOT 10 | jar 11 | 12 | com.github.blutorange 13 | closure-compiler-maven-plugin-test 14 | 1.0-SNAPSHOT 15 | .. 16 | 17 | 18 | 19 | 20 | 21 | com.github.blutorange 22 | closure-compiler-maven-plugin 23 | 24 | ${project.basedir} 25 | ${project.build.directory} 26 | false 27 | 28 | 29 | 30 | default-minify 31 | generate-resources 32 | 33 | minify 34 | 35 | 36 | true 37 | assume-function-wrapper-true.js 38 | 39 | 40 | 41 | assume-function-wrapper-false 42 | generate-resources 43 | 44 | minify 45 | 46 | 47 | false 48 | assume-function-wrapper-false.js 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/test/resources/projects/assumeFunctionWrapper/test/script.js: -------------------------------------------------------------------------------- 1 | var longVariable = 9; 2 | class Foo { 3 | init() { 4 | return longVariable + 6; 5 | } 6 | exit() { 7 | return longVariable - 6; 8 | } 9 | } 10 | console.log(typeof new Foo); 11 | console.log(x); -------------------------------------------------------------------------------- /src/test/resources/projects/bundle/bundles/minify.json: -------------------------------------------------------------------------------- 1 | { 2 | "bundles": [ 3 | { 4 | "type": "js", 5 | "name": "app-min.js", 6 | "includes": [ 7 | "includes/model/vector.js", 8 | "app.js" 9 | ] 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /src/test/resources/projects/bundle/expected/app-min.js: -------------------------------------------------------------------------------- 1 | 'use strict';class Vector2{constructor(a,b){this.x=a;this.y=b}add(a){return new Vector2(this.x+a.x,this.y+a.y)}};function main(){const a=new Vector2(1,2),b=new Vector2(3,4);console.log(a.add(b))}; -------------------------------------------------------------------------------- /src/test/resources/projects/bundle/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | com.github.blutorange 8 | closure-compiler-maven-plugin-test-bundle 9 | 1.0-SNAPSHOT 10 | jar 11 | 12 | com.github.blutorange 13 | closure-compiler-maven-plugin-test 14 | 1.0-SNAPSHOT 15 | .. 16 | 17 | 18 | 19 | 20 | 21 | com.github.blutorange 22 | closure-compiler-maven-plugin 23 | 24 | ${project.basedir} 25 | ${project.build.directory} 26 | bundles/minify.json 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/test/resources/projects/bundle/test/app.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | const a = new Vector2(1, 2); 3 | const b = new Vector2(3, 4); 4 | console.log(a.add(b)); 5 | } -------------------------------------------------------------------------------- /src/test/resources/projects/bundle/test/includes/model/vector.js: -------------------------------------------------------------------------------- 1 | class Vector2 { 2 | constructor(x, y) { 3 | this.x = x; 4 | this.y =y; 5 | } 6 | add(other) { 7 | return new Vector2(this.x + other.x, this.y + other.y); 8 | } 9 | } -------------------------------------------------------------------------------- /src/test/resources/projects/compilationlevel/expected/advanced.js: -------------------------------------------------------------------------------- 1 | 'use strict';function b(a){return 1>a?1:a*b(a-1)}const c={g:99,i:b(20),h:2,l:3};console.log(c.g);console.log(c.j);console.log(c.h); 2 | 3 | -------------------------------------------------------------------------------- /src/test/resources/projects/compilationlevel/expected/simple.js: -------------------------------------------------------------------------------- 1 | 'use strict';function inline(a){return a+1}function unused(){return helper(999999)}function helper(a){return 1>a?1:a*helper(a-1)}(function(){const a={foo:99,bar:helper(20),inline1:inline(1),inline2:inline(2)};console.log(a.foo);console.log(a.helper);console.log(a.inline1)})(); 2 | 3 | -------------------------------------------------------------------------------- /src/test/resources/projects/compilationlevel/expected/whitespace.js: -------------------------------------------------------------------------------- 1 | 'use strict';function inline(x){return x+1}function unused(){return helper(999999)}function helper(x){if(x<1)return 1;return x*helper(x-1)}(function(){const me={foo:99,bar:helper(20),inline1:inline(1),inline2:inline(2)};console.log(me.foo);console.log(me.helper);console.log(me.inline1)})(); 2 | 3 | -------------------------------------------------------------------------------- /src/test/resources/projects/compilationlevel/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | com.github.blutorange 8 | closure-compiler-maven-plugin-test-compilationlevel 9 | 1.0-SNAPSHOT 10 | jar 11 | 12 | com.github.blutorange 13 | closure-compiler-maven-plugin-test 14 | 1.0-SNAPSHOT 15 | .. 16 | 17 | 18 | 19 | 20 | 21 | com.github.blutorange 22 | closure-compiler-maven-plugin 23 | 24 | ${project.basedir} 25 | ${project.build.directory} 26 | false 27 | 28 | 29 | 30 | default-minify 31 | generate-resources 32 | 33 | minify 34 | 35 | 36 | SIMPLE_OPTIMIZATIONS 37 | simple.js 38 | 39 | 40 | 41 | whitespace 42 | generate-resources 43 | 44 | minify 45 | 46 | 47 | WHITESPACE_ONLY 48 | whitespace.js 49 | 50 | 51 | 52 | advanced 53 | generate-resources 54 | 55 | minify 56 | 57 | 58 | ADVANCED_OPTIMIZATIONS 59 | advanced.js 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/test/resources/projects/compilationlevel/test/script.js: -------------------------------------------------------------------------------- 1 | function inline(x) { 2 | return x + 1; 3 | } 4 | function unused() { 5 | return helper(999999); 6 | } 7 | function helper(x) { 8 | if (x < 1) return 1; 9 | return x * helper(x-1); 10 | } 11 | (function() { 12 | const me = { 13 | foo: 99, 14 | bar: helper(20), 15 | inline1: inline(1), 16 | inline2: inline(2) 17 | }; 18 | console.log(me.foo); 19 | console.log(me.helper); 20 | console.log(me.inline1); 21 | })(); -------------------------------------------------------------------------------- /src/test/resources/projects/define/expected/script.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';window.userAgent={};const DEBUG=!0,STRING="foo",STRING2="foo\nbar",NUMBER=42;window.userAgent.ASSUME_IE="true"; -------------------------------------------------------------------------------- /src/test/resources/projects/define/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 4.0.0 6 | com.github.blutorange 7 | closure-compiler-maven-plugin-test-define 8 | 1.0-SNAPSHOT 9 | jar 10 | 11 | com.github.blutorange 12 | closure-compiler-maven-plugin-test 13 | 1.0-SNAPSHOT 14 | .. 15 | 16 | 17 | 18 | 19 | 20 | com.github.blutorange 21 | closure-compiler-maven-plugin 22 | 23 | ${project.basedir} 24 | ${project.build.directory} 25 | 26 | 27 | 28 | default-minify 29 | generate-resources 30 | 31 | minify 32 | 33 | 34 | 35 | true 36 | foo 37 | "foo\nbar" 38 | 42 39 | "true" 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/test/resources/projects/define/test/define.js: -------------------------------------------------------------------------------- 1 | window.userAgent = {}; 2 | 3 | /** @define {boolean} */ 4 | const DEBUG = false; 5 | 6 | /** @define {string} */ 7 | const STRING = ""; 8 | 9 | /** @define {string} */ 10 | const STRING2 = ""; 11 | 12 | /** @define {number} */ 13 | const NUMBER = 0; 14 | 15 | /** @define {boolean} */ 16 | window.userAgent.ASSUME_IE = "false"; -------------------------------------------------------------------------------- /src/test/resources/projects/dynamicimportalias/expected/aliased.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | async function onMoreClicked(a) { 3 | ({enableAwesomeFeature:a} = await doTheImport("./import.js")); 4 | a(); 5 | } 6 | document.getElementById("loadMore").addEventListener(a => onMoreClicked(a)); 7 | function enableAwesomeFeature$$module$import() { 8 | console.log("The awesome feature shall now be enabled."); 9 | } 10 | var module$import = {}; 11 | module$import.enableAwesomeFeature = enableAwesomeFeature$$module$import; 12 | 13 | -------------------------------------------------------------------------------- /src/test/resources/projects/dynamicimportalias/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | com.github.blutorange 8 | closure-compiler-maven-plugin-test-allow-dynamic-imports 9 | 1.0-SNAPSHOT 10 | jar 11 | 12 | com.github.blutorange 13 | closure-compiler-maven-plugin-test 14 | 1.0-SNAPSHOT 15 | .. 16 | 17 | 18 | 19 | 20 | 21 | com.github.blutorange 22 | closure-compiler-maven-plugin 23 | 24 | ${project.basedir} 25 | ${project.build.directory} 26 | 27 | 28 | 29 | default-minify 30 | generate-resources 31 | 32 | minify 33 | 34 | 35 | true 36 | true 37 | doTheImport 38 | ECMASCRIPT_2018 39 | file:dynamic-imports-alias.js 40 | aliased.js 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/test/resources/projects/dynamicimportalias/test/dynamic-import-alias.js: -------------------------------------------------------------------------------- 1 | async function onMoreClicked(event) { 2 | const module = "./import.js"; 3 | const { enableAwesomeFeature } = await import(module); 4 | enableAwesomeFeature(); 5 | } 6 | 7 | document.getElementById("loadMore").addEventListener(e => onMoreClicked(e)); -------------------------------------------------------------------------------- /src/test/resources/projects/dynamicimportalias/test/import.js: -------------------------------------------------------------------------------- 1 | export function enableAwesomeFeature() { 2 | console.log("The awesome feature shall now be enabled."); 3 | } -------------------------------------------------------------------------------- /src/test/resources/projects/emitusestrict/expected/script.js: -------------------------------------------------------------------------------- 1 | function createTable(c,d){var b=1,a="";for(i=1;i<=c;i++){for(a+="";b<=d;)a=a+"",b+=1;a+="";b=1}document.write(a+"
"+i*b+"
")}createTable(5,3); -------------------------------------------------------------------------------- /src/test/resources/projects/emitusestrict/expected/script.strict.js: -------------------------------------------------------------------------------- 1 | 'use strict';function createTable(c,d){var b=1,a="";for(i=1;i<=c;i++){for(a+="";b<=d;)a=a+"",b+=1;a+="";b=1}document.write(a+"
"+i*b+"
")}createTable(5,3); -------------------------------------------------------------------------------- /src/test/resources/projects/emitusestrict/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | com.github.blutorange 8 | closure-compiler-maven-plugin-test-emitusestrict 9 | 1.0-SNAPSHOT 10 | jar 11 | 12 | com.github.blutorange 13 | closure-compiler-maven-plugin-test 14 | 1.0-SNAPSHOT 15 | .. 16 | 17 | 18 | 19 | 20 | 21 | com.github.blutorange 22 | closure-compiler-maven-plugin 23 | 24 | ${project.basedir} 25 | ${project.build.directory} 26 | 27 | 28 | 29 | 30 | default-minify 31 | generate-resources 32 | 33 | minify 34 | 35 | 36 | false 37 | script.js 38 | 39 | 40 | 41 | emit-use-strict 42 | generate-resources 43 | 44 | minify 45 | 46 | 47 | true 48 | script.strict.js 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/test/resources/projects/emitusestrict/test/table.js: -------------------------------------------------------------------------------- 1 | function createTable(rows, cols) { 2 | var j = 1; 3 | var output = ""; 4 | for (i = 1; i <= rows; i++) { 5 | output = output + ""; 6 | while (j <= cols) { 7 | output = output + ""; 8 | j = j + 1; 9 | } 10 | output = output + ""; 11 | j = 1; 12 | } 13 | output = output + "
" + i * j + "
"; 14 | document.write(output); 15 | } 16 | createTable(5, 3); -------------------------------------------------------------------------------- /src/test/resources/projects/externs/expected/with-externs.js: -------------------------------------------------------------------------------- 1 | 'use strict';for(var a=document.getElementById("notes"),b=[{title:"Note 1",content:"Content of Note 1"},{title:"Note 2",content:"Content of Note 2"}],c=0;c 2 | 5 | 6 | 4.0.0 7 | com.github.blutorange 8 | closure-compiler-maven-plugin-test-compilationlevel 9 | 1.0-SNAPSHOT 10 | jar 11 | 12 | com.github.blutorange 13 | closure-compiler-maven-plugin-test 14 | 1.0-SNAPSHOT 15 | .. 16 | 17 | 18 | 19 | 20 | with-externs 21 | 22 | 23 | 24 | com.github.blutorange 25 | closure-compiler-maven-plugin 26 | 27 | 28 | default-minify 29 | generate-resources 30 | 31 | minify 32 | 33 | 34 | 35 | 36 | 37 | externs/*.js 38 | 39 | 40 | 41 | with-externs.js 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | without-externs 51 | 52 | 53 | 54 | com.github.blutorange 55 | closure-compiler-maven-plugin 56 | 57 | 58 | default-minify 59 | generate-resources 60 | 61 | minify 62 | 63 | 64 | without-externs.js 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | com.github.blutorange 78 | closure-compiler-maven-plugin 79 | 80 | ${project.basedir} 81 | ${project.build.directory} 82 | false 83 | ADVANCED_OPTIMIZATIONS 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /src/test/resources/projects/externs/test/script.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A simple script for adding a list of notes to a page. The list displays 3 | * the text of each note under its title. 4 | */ 5 | 6 | /** 7 | * Creates the DOM structure for a note and adds it to the document. 8 | */ 9 | function makeNoteDom(noteTitle, noteContent, noteContainer) { 10 | // Create DOM structure to represent the note. 11 | var headerElement = textDiv(noteTitle); 12 | var contentElement = textDiv(noteContent); 13 | 14 | var newNote = document.createElement('div'); 15 | newNote.appendChild(headerElement); 16 | newNote.appendChild(contentElement); 17 | 18 | // Add the note's DOM structure to the document. 19 | noteContainer.appendChild(newNote); 20 | } 21 | 22 | /** 23 | * Iterates over a list of note data objects and creates a DOM 24 | */ 25 | function makeNotes(data, noteContainer) { 26 | for (var i = 0; i < data.length; i++) { 27 | makeNoteDom(data[i].title, data[i].content, noteContainer); 28 | } 29 | } 30 | 31 | function main() { 32 | var noteData = [ 33 | {title: 'Note 1', content: 'Content of Note 1'}, 34 | {title: 'Note 2', content: 'Content of Note 2'}]; 35 | var noteListElement = document.getElementById('notes'); 36 | makeNotes(noteData, noteListElement); 37 | } 38 | 39 | main(); -------------------------------------------------------------------------------- /src/test/resources/projects/gzip-compression/expected/merge_minify/out.js: -------------------------------------------------------------------------------- 1 | 'use strict';console.log("Logging 1 (one)");console.log("Logging 1 (one)");console.log("Logging 1 (one)");console.log("Logging 2 (two)");console.log("Logging 2 (two)");console.log("Logging 2 (two)"); 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/gzip-compression/expected/merge_minify/out.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blutorange/closure-compiler-maven-plugin/61d3b46e1dd0a51820f917d27ec47d655377459e/src/test/resources/projects/gzip-compression/expected/merge_minify/out.js.gz -------------------------------------------------------------------------------- /src/test/resources/projects/gzip-compression/expected/merge_nominify/out.js: -------------------------------------------------------------------------------- 1 | console.log("Logging 1 (one)"); 2 | console.log("Logging 1 (one)"); 3 | console.log("Logging 1 (one)"); 4 | console.log("Logging 2 (two)"); 5 | console.log("Logging 2 (two)"); 6 | console.log("Logging 2 (two)"); 7 | -------------------------------------------------------------------------------- /src/test/resources/projects/gzip-compression/expected/merge_nominify/out.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blutorange/closure-compiler-maven-plugin/61d3b46e1dd0a51820f917d27ec47d655377459e/src/test/resources/projects/gzip-compression/expected/merge_nominify/out.js.gz -------------------------------------------------------------------------------- /src/test/resources/projects/gzip-compression/expected/nomerge_minify/a.js: -------------------------------------------------------------------------------- 1 | 'use strict';console.log("Logging 1 (one)");console.log("Logging 1 (one)");console.log("Logging 1 (one)"); 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/gzip-compression/expected/nomerge_minify/a.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blutorange/closure-compiler-maven-plugin/61d3b46e1dd0a51820f917d27ec47d655377459e/src/test/resources/projects/gzip-compression/expected/nomerge_minify/a.js.gz -------------------------------------------------------------------------------- /src/test/resources/projects/gzip-compression/expected/nomerge_minify/b.js: -------------------------------------------------------------------------------- 1 | 'use strict';console.log("Logging 2 (two)");console.log("Logging 2 (two)");console.log("Logging 2 (two)"); 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/gzip-compression/expected/nomerge_minify/b.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blutorange/closure-compiler-maven-plugin/61d3b46e1dd0a51820f917d27ec47d655377459e/src/test/resources/projects/gzip-compression/expected/nomerge_minify/b.js.gz -------------------------------------------------------------------------------- /src/test/resources/projects/gzip-compression/expected/nomerge_nominify/a.js: -------------------------------------------------------------------------------- 1 | console.log("Logging 1 (one)"); 2 | console.log("Logging 1 (one)"); 3 | console.log("Logging 1 (one)"); -------------------------------------------------------------------------------- /src/test/resources/projects/gzip-compression/expected/nomerge_nominify/a.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blutorange/closure-compiler-maven-plugin/61d3b46e1dd0a51820f917d27ec47d655377459e/src/test/resources/projects/gzip-compression/expected/nomerge_nominify/a.js.gz -------------------------------------------------------------------------------- /src/test/resources/projects/gzip-compression/expected/nomerge_nominify/b.js: -------------------------------------------------------------------------------- 1 | console.log("Logging 2 (two)"); 2 | console.log("Logging 2 (two)"); 3 | console.log("Logging 2 (two)"); -------------------------------------------------------------------------------- /src/test/resources/projects/gzip-compression/expected/nomerge_nominify/b.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blutorange/closure-compiler-maven-plugin/61d3b46e1dd0a51820f917d27ec47d655377459e/src/test/resources/projects/gzip-compression/expected/nomerge_nominify/b.js.gz -------------------------------------------------------------------------------- /src/test/resources/projects/gzip-compression/test/a.js: -------------------------------------------------------------------------------- 1 | console.log("Logging 1 (one)"); 2 | console.log("Logging 1 (one)"); 3 | console.log("Logging 1 (one)"); -------------------------------------------------------------------------------- /src/test/resources/projects/gzip-compression/test/b.js: -------------------------------------------------------------------------------- 1 | console.log("Logging 2 (two)"); 2 | console.log("Logging 2 (two)"); 3 | console.log("Logging 2 (two)"); -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/encoding.txt: -------------------------------------------------------------------------------- 1 | expected/template_builder/web/html/pageHtmlEncoding/index-page-html-encoding.html=UTF-16BE 2 | src/main/resources/web/html/pageHtmlEncoding/index-page-html-encoding.html=UTF-16BE -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/node_js/web/js/pageAttributes/page-attributes.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main(){console.log("Hello, page-attributes!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/node_js/web/js/pageBasic/page-basic.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main(){console.log("Hello, page-basic!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/node_js/web/js/pageHtmlDir/page-html-dir.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main(){console.log("Hello, page-html-dir!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/node_js/web/js/pageHtmlEncoding/page-html-文字符号化方式.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main(){console.log("Hello, page-html-encoding!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/node_js/web/js/pageHtmlFiles/page-html-files.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main(){console.log("Hello, page-html-files!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/node_js/web/js/pageRoot/page-root.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main(){console.log("Hello, page-root!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/node_js/web/js/pageScriptSelector/css/page-selector-css.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main(){console.log("Hello, page-selector-css!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/node_js/web/js/pageScriptSelector/id/page-selector-id.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main(){console.log("Hello, page-selector-id!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/node_js/web/js/pageScriptSelector/xpath/page-selector-xpath.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main(){console.log("Hello, page-selector-xpath!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/node_js/web/js/pageSourcePath/page-source-path.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main(){console.log("Hello, page-source-path!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/node_js/web/js/pageSourcePathGlobal/page-source-path-global.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main(){console.log("Hello, page-source-path-global!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/node_js/web/js/pageUsePhysicalRoot/page-use-physical-root.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main(){console.log("Hello, page-use-physical-root!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/node_js/web/js/pageUsePhysicalRootGlobal/page-use-physical-root-global.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main(){console.log("Hello, page-use-physical-root-global!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/node_js/web/js/pageXhtmlFile/page-xhtml-file.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main(){console.log("Hello, page-xhtml-file!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/node_js/web/js/pageXmlFile/page-xml-file.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main(){console.log("Hello, page-xml-file!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageAttributes/index-page-attributes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page attributes 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageBasic/index-page-basic.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page basic 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageHtmlDir/index-page-html-dir.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page html dir 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageHtmlEncoding/index-page-html-encoding.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blutorange/closure-compiler-maven-plugin/61d3b46e1dd0a51820f917d27ec47d655377459e/src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageHtmlEncoding/index-page-html-encoding.html -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageHtmlFiles/a/index-a1-exclude.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, a1-exclude 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageHtmlFiles/a/index-a1-include.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, a1-include 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageHtmlFiles/a/index-a2-exclude.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, a2-exclude 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageHtmlFiles/a/index-a2-include.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, a2-include 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageHtmlFiles/b/index-b1-exclude.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, b1-exclude 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageHtmlFiles/b/index-b1-include.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, b1-include 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageHtmlFiles/b/index-b2-exclude.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, b2-exclude 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageHtmlFiles/b/index-b2-include.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, b2-include 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageRoot/index-page-root.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page root 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageScriptSelector/css/index-selector-css.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page selector CSS 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageScriptSelector/id/index-selector-id.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page selector ID 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageScriptSelector/xpath/index-selector-xpath.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page selector XPath 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageSourcePath/index-page-source-path.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page source path 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageSourcePathGlobal/index-page-source-path-global.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page source path global 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageUsePhysicalRoot/index-page-use-physical-root.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page use physical root 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageUsePhysicalRootGlobal/index-page-use-physical-root-global.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page use physical root global 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageXhtmlFile/index-page-xhtml-file.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | 9 | User Form 10 | 11 | 12 | 13 | 14 | 15 | 16 | User Name 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/expected/template_builder/web/html/pageXmlFile/index-page-xml-file.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page xml file 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageAttributes/index-page-attributes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page attributes 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageBasic/index-page-basic.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page basic 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageHtmlDir/index-page-html-dir.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page html dir 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageHtmlEncoding/index-page-html-encoding.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blutorange/closure-compiler-maven-plugin/61d3b46e1dd0a51820f917d27ec47d655377459e/src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageHtmlEncoding/index-page-html-encoding.html -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageHtmlFiles/a/index-a1-exclude.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, a1-exclude 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageHtmlFiles/a/index-a1-include.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, a1-include 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageHtmlFiles/a/index-a2-exclude.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, a2-exclude 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageHtmlFiles/a/index-a2-include.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, a2-include 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageHtmlFiles/b/index-b1-exclude.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, b1-exclude 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageHtmlFiles/b/index-b1-include.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, b1-include 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageHtmlFiles/b/index-b2-exclude.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, b2-exclude 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageHtmlFiles/b/index-b2-include.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, b2-include 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageRoot/index-page-root.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page root 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageScriptSelector/css/index-selector-css.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page selector CSS 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageScriptSelector/id/index-selector-id.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page selector ID 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageScriptSelector/xpath/index-selector-xpath.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page selector XPath 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageSourcePath/index-page-source-path.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page source path 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageSourcePathGlobal/index-page-source-path-global.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page source path global 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageUsePhysicalRoot/index-page-use-physical-root.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page use physical root 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageUsePhysicalRootGlobal/index-page-use-physical-root-global.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page use physical root global 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageXhtmlFile/index-page-xhtml-file.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | 9 | User Form 10 | 11 | 12 | 13 | 14 | 15 | 16 | User Name 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/src/main/resources/web/html/pageXmlFile/index-page-xml-file.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello, page xml file 4 | 5 | 6 |
7 |

Hello!

8 |
9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/test/web/js/pageAttributes/page-attributes.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | function sayHello(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello("page-attributes"); 6 | } -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/test/web/js/pageBasic/page-basic.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | function sayHello(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello("page-basic"); 6 | } -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/test/web/js/pageHtmlDir/page-html-dir.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | function sayHello(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello("page-html-dir"); 6 | } -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/test/web/js/pageHtmlEncoding/page-html-文字符号化方式.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | function sayHello(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello("page-html-encoding"); 6 | } -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/test/web/js/pageHtmlFiles/page-html-files.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | function sayHello(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello("page-html-files"); 6 | } -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/test/web/js/pageRoot/page-root.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | function sayHello(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello("page-root"); 6 | } -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/test/web/js/pageScriptSelector/css/page-selector-css.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | function sayHello(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello("page-selector-css"); 6 | } -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/test/web/js/pageScriptSelector/id/page-selector-id.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | function sayHello(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello("page-selector-id"); 6 | } -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/test/web/js/pageScriptSelector/xpath/page-selector-xpath.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | function sayHello(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello("page-selector-xpath"); 6 | } -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/test/web/js/pageSourcePath/page-source-path.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | function sayHello(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello("page-source-path"); 6 | } -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/test/web/js/pageSourcePathGlobal/page-source-path-global.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | function sayHello(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello("page-source-path-global"); 6 | } -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/test/web/js/pageUsePhysicalRoot/page-use-physical-root.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | function sayHello(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello("page-use-physical-root"); 6 | } -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/test/web/js/pageUsePhysicalRootGlobal/page-use-physical-root-global.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | function sayHello(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello("page-use-physical-root-global"); 6 | } -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/test/web/js/pageXhtmlFile/page-xhtml-file.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | function sayHello(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello("page-xhtml-file"); 6 | } -------------------------------------------------------------------------------- /src/test/resources/projects/htmlUpdate/test/web/js/pageXmlFile/page-xml-file.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | function sayHello(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello("page-xml-file"); 6 | } -------------------------------------------------------------------------------- /src/test/resources/projects/isolatepolyfills/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | com.github.blutorange 8 | closure-compiler-maven-plugin-test-isolate-polyfills 9 | 1.0-SNAPSHOT 10 | jar 11 | 12 | com.github.blutorange 13 | closure-compiler-maven-plugin-test 14 | 1.0-SNAPSHOT 15 | .. 16 | 17 | 18 | 19 | 20 | 21 | com.github.blutorange 22 | closure-compiler-maven-plugin 23 | 24 | ${project.basedir} 25 | ${project.build.directory} 26 | 27 | 28 | 29 | default-minify 30 | generate-resources 31 | 32 | minify 33 | 34 | 35 | true 36 | false 37 | true 38 | isolate-polyfills-false.js 39 | 40 | map-set.js 41 | 42 | 43 | 44 | 45 | polyfill-true 46 | generate-resources 47 | 48 | minify 49 | 50 | 51 | true 52 | true 53 | true 54 | isolate-polyfills-true.js 55 | 56 | map-set.js 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/test/resources/projects/isolatepolyfills/test/map-set.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @template T 3 | * @param {T[]} items 4 | * @return {T[]} 5 | */ 6 | function makeUnique(items) { 7 | const set = new Set(items); 8 | return Array.from(set); 9 | } 10 | /** 11 | * @template T 12 | * @param {T[]} items 13 | * @param {(item: T) => any} keyExtractor 14 | */ 15 | function uniqueByKey(items, keyExtractor) { 16 | const map = new Map(items.map(item => [keyExtractor(item), item])); 17 | return Array.from(map.values()); 18 | } -------------------------------------------------------------------------------- /src/test/resources/projects/jquery/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 4.0.0 6 | com.github.blutorange 7 | closure-compiler-maven-plugin-test-minimal 8 | 1.0-SNAPSHOT 9 | jar 10 | 11 | com.github.blutorange 12 | closure-compiler-maven-plugin-test 13 | 1.0-SNAPSHOT 14 | .. 15 | 16 | 17 | 18 | 19 | 20 | com.github.blutorange 21 | closure-compiler-maven-plugin 22 | 23 | ${project.basedir} 24 | ${project.build.directory} 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/test/resources/projects/minimal/expected/script.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main(){console.log("Hello, blutorange!")}; -------------------------------------------------------------------------------- /src/test/resources/projects/minimal/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 4.0.0 6 | com.github.blutorange 7 | closure-compiler-maven-plugin-test-minimal 8 | 1.0-SNAPSHOT 9 | jar 10 | 11 | com.github.blutorange 12 | closure-compiler-maven-plugin-test 13 | 1.0-SNAPSHOT 14 | ../parent/pom.xml 15 | 16 | 17 | 18 | 19 | 20 | com.github.blutorange 21 | closure-compiler-maven-plugin 22 | 23 | ${project.basedir} 24 | ${project.build.directory} 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/test/resources/projects/minimal/test/hello.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | function sayHello(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello("blutorange"); 6 | } -------------------------------------------------------------------------------- /src/test/resources/projects/nodemodules/expected/default.js: -------------------------------------------------------------------------------- 1 | 'use strict';function toArray$$module$node_modules$to_array$index(c,b){for(var d=[],a=(b=b||0)||0;a 2 | 4 | 5 | 4.0.0 6 | com.github.blutorange 7 | closure-compiler-maven-plugin-test-nodemodules 8 | 1.0-SNAPSHOT 9 | jar 10 | 11 | com.github.blutorange 12 | closure-compiler-maven-plugin-test 13 | 1.0-SNAPSHOT 14 | .. 15 | 16 | 17 | 18 | 19 | 20 | com.github.blutorange 21 | closure-compiler-maven-plugin 22 | 23 | ${project.basedir} 24 | ${project.build.directory} 25 | NODE 26 | PRUNE 27 | 28 | file:main.js 29 | 30 | default.js 31 | 32 | 33 | 34 | default-minify 35 | generate-resources 36 | 37 | minify 38 | 39 | 40 | test/default 41 | 42 | 43 | 44 | jsmoduleroot 45 | generate-resources 46 | 47 | minify 48 | 49 | 50 | 51 | npm 52 | 53 | test/jsmoduleroot 54 | jsmoduleroot.js 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/test/resources/projects/nodemodules/test/default/main.js: -------------------------------------------------------------------------------- 1 | import { toArray } from "to-array"; 2 | console.log(toArray(document.getElementsByClassName("foo"))); -------------------------------------------------------------------------------- /src/test/resources/projects/nodemodules/test/default/node_modules/to-array/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.log 3 | *.err -------------------------------------------------------------------------------- /src/test/resources/projects/nodemodules/test/default/node_modules/to-array/LICENCE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Raynos. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /src/test/resources/projects/nodemodules/test/default/node_modules/to-array/README.md: -------------------------------------------------------------------------------- 1 | # to-array 2 | 3 | Turn an array like into an array 4 | 5 | ## Example 6 | 7 | ``` js 8 | var toArray = require("to-array") 9 | , elems = document.links 10 | 11 | var array = toArray(elems) 12 | ``` 13 | 14 | ## Installation 15 | 16 | `npm install to-array` 17 | 18 | ## Contributors 19 | 20 | - Raynos 21 | 22 | ## MIT Licenced 23 | -------------------------------------------------------------------------------- /src/test/resources/projects/nodemodules/test/default/node_modules/to-array/index.js: -------------------------------------------------------------------------------- 1 | export function toArray(list, index) { 2 | var array = [] 3 | 4 | index = index || 0 5 | 6 | for (var i = index || 0; i < list.length; i++) { 7 | array[i - index] = list[i] 8 | } 9 | 10 | return array 11 | } 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/nodemodules/test/default/node_modules/to-array/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "_from": "to-array", 3 | "_id": "to-array@0.1.4", 4 | "_inBundle": false, 5 | "_integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=", 6 | "_location": "/to-array", 7 | "_phantomChildren": {}, 8 | "_requested": { 9 | "type": "tag", 10 | "registry": true, 11 | "raw": "to-array", 12 | "name": "to-array", 13 | "escapedName": "to-array", 14 | "rawSpec": "", 15 | "saveSpec": null, 16 | "fetchSpec": "latest" 17 | }, 18 | "_requiredBy": [ 19 | "#USER", 20 | "/" 21 | ], 22 | "_resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz", 23 | "_shasum": "17e6c11f73dd4f3d74cda7a4ff3238e9ad9bf890", 24 | "_spec": "to-array", 25 | "_where": "/tmp/test", 26 | "author": { 27 | "name": "Raynos", 28 | "email": "raynos2@gmail.com" 29 | }, 30 | "bugs": { 31 | "url": "https://github.com/Raynos/to-array/issues", 32 | "email": "raynos2@gmail.com" 33 | }, 34 | "bundleDependencies": false, 35 | "component": { 36 | "scripts": { 37 | "to-array/index.js": "index.js" 38 | } 39 | }, 40 | "contributors": [ 41 | { 42 | "name": "Jake Verbaten" 43 | } 44 | ], 45 | "dependencies": {}, 46 | "deprecated": false, 47 | "description": "Turn an array like into an array", 48 | "devDependencies": { 49 | "tap": "~0.3.1" 50 | }, 51 | "homepage": "https://github.com/Raynos/to-array", 52 | "keywords": [], 53 | "licenses": [ 54 | { 55 | "type": "MIT", 56 | "url": "http://github.com/Raynos/to-array/raw/master/LICENSE" 57 | } 58 | ], 59 | "main": "index", 60 | "name": "to-array", 61 | "repository": { 62 | "type": "git", 63 | "url": "git://github.com/Raynos/to-array.git" 64 | }, 65 | "scripts": { 66 | "test": "tap --stderr --tap ./test" 67 | }, 68 | "version": "0.1.4" 69 | } 70 | -------------------------------------------------------------------------------- /src/test/resources/projects/nodemodules/test/default/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "to-array": { 8 | "version": "0.1.4", 9 | "resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz", 10 | "integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/resources/projects/nodemodules/test/default/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "to-array": "^0.1.4" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/projects/nodemodules/test/jsmoduleroot/main.js: -------------------------------------------------------------------------------- 1 | import { toArray } from "to-array"; 2 | console.log(toArray(document.getElementsByClassName("bar"))); -------------------------------------------------------------------------------- /src/test/resources/projects/nodemodules/test/jsmoduleroot/npm/node_modules/to-array/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.log 3 | *.err -------------------------------------------------------------------------------- /src/test/resources/projects/nodemodules/test/jsmoduleroot/npm/node_modules/to-array/LICENCE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Raynos. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /src/test/resources/projects/nodemodules/test/jsmoduleroot/npm/node_modules/to-array/README.md: -------------------------------------------------------------------------------- 1 | # to-array 2 | 3 | Turn an array like into an array 4 | 5 | ## Example 6 | 7 | ``` js 8 | var toArray = require("to-array") 9 | , elems = document.links 10 | 11 | var array = toArray(elems) 12 | ``` 13 | 14 | ## Installation 15 | 16 | `npm install to-array` 17 | 18 | ## Contributors 19 | 20 | - Raynos 21 | 22 | ## MIT Licenced 23 | -------------------------------------------------------------------------------- /src/test/resources/projects/nodemodules/test/jsmoduleroot/npm/node_modules/to-array/index.js: -------------------------------------------------------------------------------- 1 | export function toArray(list, index) { 2 | var array = [] 3 | 4 | index = index || 0 5 | 6 | for (var i = index || 0; i < list.length; i++) { 7 | array[i - index] = list[i] 8 | } 9 | 10 | return array 11 | } 12 | -------------------------------------------------------------------------------- /src/test/resources/projects/nodemodules/test/jsmoduleroot/npm/node_modules/to-array/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "_from": "to-array", 3 | "_id": "to-array@0.1.4", 4 | "_inBundle": false, 5 | "_integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=", 6 | "_location": "/to-array", 7 | "_phantomChildren": {}, 8 | "_requested": { 9 | "type": "tag", 10 | "registry": true, 11 | "raw": "to-array", 12 | "name": "to-array", 13 | "escapedName": "to-array", 14 | "rawSpec": "", 15 | "saveSpec": null, 16 | "fetchSpec": "latest" 17 | }, 18 | "_requiredBy": [ 19 | "#USER", 20 | "/" 21 | ], 22 | "_resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz", 23 | "_shasum": "17e6c11f73dd4f3d74cda7a4ff3238e9ad9bf890", 24 | "_spec": "to-array", 25 | "_where": "/tmp/test", 26 | "author": { 27 | "name": "Raynos", 28 | "email": "raynos2@gmail.com" 29 | }, 30 | "bugs": { 31 | "url": "https://github.com/Raynos/to-array/issues", 32 | "email": "raynos2@gmail.com" 33 | }, 34 | "bundleDependencies": false, 35 | "component": { 36 | "scripts": { 37 | "to-array/index.js": "index.js" 38 | } 39 | }, 40 | "contributors": [ 41 | { 42 | "name": "Jake Verbaten" 43 | } 44 | ], 45 | "dependencies": {}, 46 | "deprecated": false, 47 | "description": "Turn an array like into an array", 48 | "devDependencies": { 49 | "tap": "~0.3.1" 50 | }, 51 | "homepage": "https://github.com/Raynos/to-array", 52 | "keywords": [], 53 | "licenses": [ 54 | { 55 | "type": "MIT", 56 | "url": "http://github.com/Raynos/to-array/raw/master/LICENSE" 57 | } 58 | ], 59 | "main": "index", 60 | "name": "to-array", 61 | "repository": { 62 | "type": "git", 63 | "url": "git://github.com/Raynos/to-array.git" 64 | }, 65 | "scripts": { 66 | "test": "tap --stderr --tap ./test" 67 | }, 68 | "version": "0.1.4" 69 | } 70 | -------------------------------------------------------------------------------- /src/test/resources/projects/nodemodules/test/jsmoduleroot/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "to-array": { 8 | "version": "0.1.4", 9 | "resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz", 10 | "integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/resources/projects/nodemodules/test/jsmoduleroot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "to-array": "^0.1.4" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/projects/outputfilename/expected/merge+minify.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main1(){console.log("Hello, blutorange1!")};function main2(){console.log("Hello, blutorange2!")};function main3(){console.log("Hello, blutorange3!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/outputfilename/expected/merge-only.js: -------------------------------------------------------------------------------- 1 | function main1() { 2 | function sayHello1(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello1("blutorange1"); 6 | } // comment 1 7 | function main2() { 8 | function sayHello2(name) { 9 | console.log("Hello, " + name + "!"); 10 | } 11 | sayHello2("blutorange2"); 12 | } // comment 2 13 | function main3() { 14 | function sayHello3(name) { 15 | console.log("Hello, " + name + "!"); 16 | } 17 | sayHello3("blutorange3"); 18 | } // comment 3 19 | -------------------------------------------------------------------------------- /src/test/resources/projects/outputfilename/expected/minify-only-hello1.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main1(){console.log("Hello, blutorange1!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/outputfilename/expected/minify-only-hello2.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main2(){console.log("Hello, blutorange2!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/outputfilename/expected/minify-only-hello3.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main3(){console.log("Hello, blutorange3!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/outputfilename/expected/no-merge-no-minify-hello1.js: -------------------------------------------------------------------------------- 1 | function main1() { 2 | function sayHello1(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello1("blutorange1"); 6 | } // comment 1 -------------------------------------------------------------------------------- /src/test/resources/projects/outputfilename/expected/no-merge-no-minify-hello2.js: -------------------------------------------------------------------------------- 1 | function main2() { 2 | function sayHello2(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello2("blutorange2"); 6 | } // comment 2 -------------------------------------------------------------------------------- /src/test/resources/projects/outputfilename/expected/no-merge-no-minify-hello3.js: -------------------------------------------------------------------------------- 1 | function main3() { 2 | function sayHello3(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello3("blutorange3"); 6 | } // comment 3 -------------------------------------------------------------------------------- /src/test/resources/projects/outputfilename/expected/placeholder-extension-hello-mjs.js: -------------------------------------------------------------------------------- 1 | 'use strict';function mainMjs(){console.log("Hello, blutorangeMjs!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/outputfilename/expected/placeholder-filename-hello1.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main1(){console.log("Hello, blutorange1!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/outputfilename/expected/placeholder-filename-hello2.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main2(){console.log("Hello, blutorange2!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/outputfilename/expected/placeholder-filename-hello3.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main3(){console.log("Hello, blutorange3!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/outputfilename/expected/placeholder-path-subdir-hello3.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main3(){console.log("Hello, blutorange3!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/outputfilename/test/hello.mjs: -------------------------------------------------------------------------------- 1 | function mainMjs() { 2 | function sayHelloMjs(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHelloMjs("blutorangeMjs"); 6 | } // comment -------------------------------------------------------------------------------- /src/test/resources/projects/outputfilename/test/hello1.js: -------------------------------------------------------------------------------- 1 | function main1() { 2 | function sayHello1(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello1("blutorange1"); 6 | } // comment 1 -------------------------------------------------------------------------------- /src/test/resources/projects/outputfilename/test/hello2.js: -------------------------------------------------------------------------------- 1 | function main2() { 2 | function sayHello2(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello2("blutorange2"); 6 | } // comment 2 -------------------------------------------------------------------------------- /src/test/resources/projects/outputfilename/test/subdir/hello3.js: -------------------------------------------------------------------------------- 1 | function main3() { 2 | function sayHello3(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello3("blutorange3"); 6 | } // comment 3 -------------------------------------------------------------------------------- /src/test/resources/projects/outputwrapper/expected/jsstring.js: -------------------------------------------------------------------------------- 1 | jQuery(function(){eval('\'use strict\';function performCheck(a){console.log(\"checking form...\")}const div=document.getElementById(\"button[name=\'check\']\");div.addEventListener(\"click\",a=>performCheck(a));')}); -------------------------------------------------------------------------------- /src/test/resources/projects/outputwrapper/expected/simple.js: -------------------------------------------------------------------------------- 1 | jQuery(function(){'use strict';function performCheck(a){console.log("checking form...")}const div=document.getElementById("button[name='check']");div.addEventListener("click",a=>performCheck(a));}); -------------------------------------------------------------------------------- /src/test/resources/projects/outputwrapper/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | com.github.blutorange 8 | closure-compiler-maven-plugin-test-outputwrapper 9 | 1.0-SNAPSHOT 10 | jar 11 | 12 | com.github.blutorange 13 | closure-compiler-maven-plugin-test 14 | 1.0-SNAPSHOT 15 | .. 16 | 17 | 18 | 19 | 20 | 21 | com.github.blutorange 22 | closure-compiler-maven-plugin 23 | 24 | ${project.basedir} 25 | ${project.build.directory} 26 | 27 | 28 | 29 | default-minify 30 | generate-resources 31 | 32 | minify 33 | 34 | 35 | jQuery(function(){%output%}); 36 | simple.js 37 | 38 | 39 | 40 | jsstring 41 | generate-resources 42 | 43 | minify 44 | 45 | 46 | jQuery(function(){eval('%output|jsstring%')}); 47 | jsstring.js 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/test/resources/projects/outputwrapper/test/onDocumentReady.js: -------------------------------------------------------------------------------- 1 | function performCheck(event) { 2 | console.log("checking form..."); 3 | } 4 | const div = document.getElementById("button[name='check']"); 5 | div.addEventListener("click", event => performCheck(event)); -------------------------------------------------------------------------------- /src/test/resources/projects/overwriteInputFilesDisabled/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | com.github.blutorange 8 | closure-compiler-maven-plugin-test-overwrite-input-files-disabled 9 | 1.0-SNAPSHOT 10 | jar 11 | 12 | com.github.blutorange 13 | closure-compiler-maven-plugin-test 14 | 1.0-SNAPSHOT 15 | .. 16 | 17 | 18 | 19 | 20 | 21 | 22 | maven-resources-plugin 23 | 3.1.0 24 | 25 | 26 | copy-resources 27 | generate-resources 28 | 29 | copy-resources 30 | 31 | 32 | ${project.build.directory}/test 33 | 34 | 35 | ${project.basedir}/test 36 | false 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | com.github.blutorange 45 | closure-compiler-maven-plugin 46 | 47 | ${project.build.directory} 48 | ${project.build.directory} 49 | #{path}/#{basename}.#{extension} 50 | **/*.js 51 | true 52 | false 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/test/resources/projects/overwriteInputFilesDisabled/test/fileC.js: -------------------------------------------------------------------------------- 1 | console.log( "fileC.js" ); -------------------------------------------------------------------------------- /src/test/resources/projects/overwriteInputFilesDisabled/test/subDirA/fileA.js: -------------------------------------------------------------------------------- 1 | console.log( "fileA.js" ); -------------------------------------------------------------------------------- /src/test/resources/projects/overwriteInputFilesDisabled/test/subDirA/nested/fileD.js: -------------------------------------------------------------------------------- 1 | console.log( "fileD.js" ); -------------------------------------------------------------------------------- /src/test/resources/projects/overwriteInputFilesDisabled/test/subDirB/fileB.js: -------------------------------------------------------------------------------- 1 | console.log( "fileB.js" ); -------------------------------------------------------------------------------- /src/test/resources/projects/overwriteInputFilesEnabled/expected/fileC.js: -------------------------------------------------------------------------------- 1 | 'use strict';console.log("fileC.js"); -------------------------------------------------------------------------------- /src/test/resources/projects/overwriteInputFilesEnabled/expected/subDirA/fileA.js: -------------------------------------------------------------------------------- 1 | 'use strict';console.log("fileA.js"); -------------------------------------------------------------------------------- /src/test/resources/projects/overwriteInputFilesEnabled/expected/subDirA/nested/fileD.js: -------------------------------------------------------------------------------- 1 | 'use strict';console.log("fileD.js"); -------------------------------------------------------------------------------- /src/test/resources/projects/overwriteInputFilesEnabled/expected/subDirB/fileB.js: -------------------------------------------------------------------------------- 1 | 'use strict';console.log("fileB.js"); -------------------------------------------------------------------------------- /src/test/resources/projects/overwriteInputFilesEnabled/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | com.github.blutorange 8 | closure-compiler-maven-plugin-test-overwrite-input-files-enabled 9 | 1.0-SNAPSHOT 10 | jar 11 | 12 | com.github.blutorange 13 | closure-compiler-maven-plugin-test 14 | 1.0-SNAPSHOT 15 | .. 16 | 17 | 18 | 19 | 20 | 21 | 22 | maven-resources-plugin 23 | 3.1.0 24 | 25 | 26 | copy-resources 27 | generate-resources 28 | 29 | copy-resources 30 | 31 | 32 | ${project.build.directory}/test 33 | 34 | 35 | ${project.basedir}/test 36 | false 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | com.github.blutorange 45 | closure-compiler-maven-plugin 46 | 47 | ${project.build.directory} 48 | ${project.build.directory} 49 | #{path}/#{basename}.#{extension} 50 | **/*.js 51 | true 52 | true 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/test/resources/projects/overwriteInputFilesEnabled/test/fileC.js: -------------------------------------------------------------------------------- 1 | console.log( "fileC.js" ); -------------------------------------------------------------------------------- /src/test/resources/projects/overwriteInputFilesEnabled/test/subDirA/fileA.js: -------------------------------------------------------------------------------- 1 | console.log( "fileA.js" ); -------------------------------------------------------------------------------- /src/test/resources/projects/overwriteInputFilesEnabled/test/subDirA/nested/fileD.js: -------------------------------------------------------------------------------- 1 | console.log( "fileD.js" ); -------------------------------------------------------------------------------- /src/test/resources/projects/overwriteInputFilesEnabled/test/subDirB/fileB.js: -------------------------------------------------------------------------------- 1 | console.log( "fileB.js" ); -------------------------------------------------------------------------------- /src/test/resources/projects/parent/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | com.github.blutorange 8 | closure-compiler-maven-plugin-test 9 | 1.0-SNAPSHOT 10 | pom 11 | 12 | 13 | UTF-8 14 | 2.33.0-SNAPSHOT 15 | 3.3.1 16 | 17 | 18 | 19 | 20 | com.github.blutorange 21 | closure-compiler-maven-plugin 22 | ${closure.compiler.maven.plugin.version} 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | org.apache.maven.plugins 31 | maven-resources-plugin 32 | ${maven-resources-plugin.version} 33 | 34 | 35 | com.github.blutorange 36 | closure-compiler-maven-plugin 37 | ${closure.compiler.maven.plugin.version} 38 | 39 | UTF8 40 | test 41 | test 42 | 43 | **/*.js 44 | 45 | 46 | OFF 47 | OFF 48 | OFF 49 | OFF 50 | OFF 51 | 52 | 53 | 54 | 55 | default-minify 56 | 57 | minify 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /src/test/resources/projects/prefersinglequotes/expected/prefer-single-quotes-false.js: -------------------------------------------------------------------------------- 1 | 'use strict';function hello(a){alert(a)}hello("New User");hello("New User");hello("New '\"User");hello("New '\"User"); -------------------------------------------------------------------------------- /src/test/resources/projects/prefersinglequotes/expected/prefer-single-quotes-true.js: -------------------------------------------------------------------------------- 1 | 'use strict';function hello(a){alert(a)}hello('New User');hello('New User');hello('New \'"User');hello('New \'"User'); -------------------------------------------------------------------------------- /src/test/resources/projects/prefersinglequotes/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | com.github.blutorange 8 | closure-compiler-maven-plugin-test-prefersinglequotes 9 | 1.0-SNAPSHOT 10 | jar 11 | 12 | com.github.blutorange 13 | closure-compiler-maven-plugin-test 14 | 1.0-SNAPSHOT 15 | .. 16 | 17 | 18 | 19 | 20 | 21 | com.github.blutorange 22 | closure-compiler-maven-plugin 23 | 24 | ${project.basedir} 25 | ${project.build.directory} 26 | 27 | 28 | 29 | default-minify 30 | generate-resources 31 | 32 | minify 33 | 34 | 35 | false 36 | prefer-single-quotes-false.js 37 | 38 | 39 | 40 | prefer-single-quotes-true 41 | generate-resources 42 | 43 | minify 44 | 45 | 46 | true 47 | prefer-single-quotes-true.js 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/test/resources/projects/prefersinglequotes/test/hello.js: -------------------------------------------------------------------------------- 1 | // A simple function. 2 | function hello(longName) { 3 | alert(longName); 4 | } 5 | hello('New User'); 6 | hello("New User"); 7 | hello('New \'"User'); 8 | hello("New '\"User"); -------------------------------------------------------------------------------- /src/test/resources/projects/prettyprint/expected/script.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | function hello(a) { 3 | alert("Hello, " + a); 4 | } 5 | hello("New User"); -------------------------------------------------------------------------------- /src/test/resources/projects/prettyprint/expected/script.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';function hello(a){alert("Hello, "+a)}hello("New User"); -------------------------------------------------------------------------------- /src/test/resources/projects/prettyprint/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | com.github.blutorange 8 | closure-compiler-maven-plugin-test-prettyprint 9 | 1.0-SNAPSHOT 10 | jar 11 | 12 | com.github.blutorange 13 | closure-compiler-maven-plugin-test 14 | 1.0-SNAPSHOT 15 | .. 16 | 17 | 18 | 19 | 20 | 21 | com.github.blutorange 22 | closure-compiler-maven-plugin 23 | 24 | ${project.basedir} 25 | ${project.build.directory} 26 | 27 | 28 | 29 | default-minify 30 | generate-resources 31 | 32 | minify 33 | 34 | 35 | false 36 | script.min.js 37 | 38 | 39 | 40 | pretty-print 41 | generate-resources 42 | 43 | minify 44 | 45 | 46 | true 47 | script.js 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/test/resources/projects/prettyprint/test/hello.js: -------------------------------------------------------------------------------- 1 | // A simple function. 2 | function hello(longName) { 3 | alert('Hello, ' + longName); 4 | } 5 | hello('New User'); -------------------------------------------------------------------------------- /src/test/resources/projects/rewritepolyfills/expected/no-map-set.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | function makeUnique(a) { 3 | return a; 4 | } 5 | function uniqueByKey(a, b) { 6 | return a; 7 | } 8 | ; -------------------------------------------------------------------------------- /src/test/resources/projects/rewritepolyfills/expected/polyfills-false.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | function makeUnique(a) { 3 | a = new Set(a); 4 | return Array.from(a); 5 | } 6 | function uniqueByKey(a, c) { 7 | a = new Map(a.map(b => [c(b), b])); 8 | return Array.from(a.values()); 9 | } 10 | ; -------------------------------------------------------------------------------- /src/test/resources/projects/rewritepolyfills/test/map-set.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @template T 3 | * @param {T[]} items 4 | * @return {T[]} 5 | */ 6 | function makeUnique(items) { 7 | const set = new Set(items); 8 | return Array.from(set); 9 | } 10 | /** 11 | * @template T 12 | * @param {T[]} items 13 | * @param {(item: T) => any} keyExtractor 14 | */ 15 | function uniqueByKey(items, keyExtractor) { 16 | const map = new Map(items.map(item => [keyExtractor(item), item])); 17 | return Array.from(map.values()); 18 | } -------------------------------------------------------------------------------- /src/test/resources/projects/rewritepolyfills/test/no-map-set.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @template T 3 | * @param {T[]} items 4 | * @return {T[]} 5 | */ 6 | function makeUnique(items) { 7 | // implement... 8 | return items; 9 | } 10 | /** 11 | * @template T 12 | * @param {T[]} items 13 | * @param {(item: T) => any} keyExtractor 14 | */ 15 | function uniqueByKey(items, keyExtractor) { 16 | // implement... 17 | return items; 18 | } -------------------------------------------------------------------------------- /src/test/resources/projects/skip/expected/default.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main(){console.log("Hello, blutorange!")};function main2(){console.log("Hello2, blutorange2!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/skip/expected/hello.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main(){console.log("Hello, blutorange!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/skip/expected/hello2.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main2(){console.log("Hello2, blutorange2!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/skip/expected/skipBoth/hello.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | function sayHello(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello("blutorange"); 6 | } -------------------------------------------------------------------------------- /src/test/resources/projects/skip/expected/skipBoth/hello2.js: -------------------------------------------------------------------------------- 1 | function main2() { 2 | function sayHello2(name2) { 3 | console.log("Hello2, " + name2 + "!"); 4 | } 5 | sayHello2("blutorange2"); 6 | } -------------------------------------------------------------------------------- /src/test/resources/projects/skip/expected/skipMinify.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | function sayHello(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello("blutorange"); 6 | } 7 | function main2() { 8 | function sayHello2(name2) { 9 | console.log("Hello2, " + name2 + "!"); 10 | } 11 | sayHello2("blutorange2"); 12 | } 13 | -------------------------------------------------------------------------------- /src/test/resources/projects/skip/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | com.github.blutorange 8 | closure-compiler-maven-plugin-test-minimal 9 | 1.0-SNAPSHOT 10 | jar 11 | 12 | com.github.blutorange 13 | closure-compiler-maven-plugin-test 14 | 1.0-SNAPSHOT 15 | .. 16 | 17 | 18 | 19 | 20 | 21 | com.github.blutorange 22 | closure-compiler-maven-plugin 23 | 24 | ${project.basedir} 25 | ${project.build.directory} 26 | 27 | 28 | 29 | default-minify 30 | generate-resources 31 | 32 | minify 33 | 34 | 35 | false 36 | false 37 | default.js 38 | 39 | 40 | 41 | skipMinify 42 | generate-resources 43 | 44 | minify 45 | 46 | 47 | true 48 | false 49 | skipMinify.js 50 | 51 | 52 | 53 | skipMerge 54 | generate-resources 55 | 56 | minify 57 | 58 | 59 | false 60 | true 61 | #{basename}.#{extension} 62 | 63 | 64 | 65 | skipBoth 66 | generate-resources 67 | 68 | minify 69 | 70 | 71 | true 72 | true 73 | test/skipBoth 74 | #{basename}.#{extension} 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /src/test/resources/projects/skip/test/hello.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | function sayHello(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello("blutorange"); 6 | } -------------------------------------------------------------------------------- /src/test/resources/projects/skip/test/hello2.js: -------------------------------------------------------------------------------- 1 | function main2() { 2 | function sayHello2(name2) { 3 | console.log("Hello2, " + name2 + "!"); 4 | } 5 | sayHello2("blutorange2"); 6 | } -------------------------------------------------------------------------------- /src/test/resources/projects/skipall/expected/nofiles: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blutorange/closure-compiler-maven-plugin/61d3b46e1dd0a51820f917d27ec47d655377459e/src/test/resources/projects/skipall/expected/nofiles -------------------------------------------------------------------------------- /src/test/resources/projects/skipall/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 4.0.0 6 | com.github.blutorange 7 | closure-compiler-maven-plugin-test-skipall 8 | 1.0-SNAPSHOT 9 | jar 10 | 11 | com.github.blutorange 12 | closure-compiler-maven-plugin-test 13 | 1.0-SNAPSHOT 14 | .. 15 | 16 | 17 | 18 | 19 | 20 | com.github.blutorange 21 | closure-compiler-maven-plugin 22 | 23 | ${project.basedir} 24 | ${project.build.directory} 25 | true 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/test/resources/projects/skipall/test/hello.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | function sayHello(name) { 3 | console.log("Hello, " + name + "!"); 4 | } 5 | sayHello("blutorange"); 6 | } -------------------------------------------------------------------------------- /src/test/resources/projects/skipif/expected/script.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main(){console.log("Hello, skipper!")}; 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/skipif/newer/script.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';function main(){console.log("Hello, skipper!")}; -------------------------------------------------------------------------------- /src/test/resources/projects/skipif/test/hello.js: -------------------------------------------------------------------------------- 1 | throw new Error("This file should not have been processed") 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/skipsome/existing/script1.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';console.log("This file script1.js should have been processed"); -------------------------------------------------------------------------------- /src/test/resources/projects/skipsome/existing/script3.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';console.log("This file script3.js should have been processed"); -------------------------------------------------------------------------------- /src/test/resources/projects/skipsome/existing/script4.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';console.log("This file script4.js should have been processed"); -------------------------------------------------------------------------------- /src/test/resources/projects/skipsome/expected/script1.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';console.log("This file script1.js should have been processed"); -------------------------------------------------------------------------------- /src/test/resources/projects/skipsome/expected/script2.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';console.log("This file script2.js should have been processed"); -------------------------------------------------------------------------------- /src/test/resources/projects/skipsome/expected/script3.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';console.log("This file script3.js should have been processed"); -------------------------------------------------------------------------------- /src/test/resources/projects/skipsome/expected/script4.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';console.log("This file script4.js should have been processed"); -------------------------------------------------------------------------------- /src/test/resources/projects/skipsome/expected/script5.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';console.log("This file script5.js should have been processed"); -------------------------------------------------------------------------------- /src/test/resources/projects/skipsome/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 4.0.0 6 | com.github.blutorange 7 | closure-compiler-maven-plugin-test-skipsome 8 | 1.0-SNAPSHOT 9 | jar 10 | 11 | com.github.blutorange 12 | closure-compiler-maven-plugin-test 13 | 1.0-SNAPSHOT 14 | .. 15 | 16 | 17 | 18 | 19 | 20 | org.apache.maven.plugins 21 | maven-antrun-plugin 22 | 1.8 23 | 24 | 25 | process-resources 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | run 35 | 36 | 37 | 38 | 39 | 40 | 41 | com.github.blutorange 42 | closure-compiler-maven-plugin 43 | 44 | ${project.basedir} 45 | ${project.build.directory} 46 | true 47 | EXISTS 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/test/resources/projects/skipsome/test/script1.js: -------------------------------------------------------------------------------- 1 | throw new Error("This file script1.js should not have been processed") 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/skipsome/test/script2.js: -------------------------------------------------------------------------------- 1 | console.log("This file script2.js should have been processed") -------------------------------------------------------------------------------- /src/test/resources/projects/skipsome/test/script3.js: -------------------------------------------------------------------------------- 1 | throw new Error("This file script3.js should not have been processed") 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/skipsome/test/script4.js: -------------------------------------------------------------------------------- 1 | throw new Error("This file script4.js should not have been processed") 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/skipsome/test/script5.js: -------------------------------------------------------------------------------- 1 | console.log("This file script5.js should have been processed") 2 | -------------------------------------------------------------------------------- /src/test/resources/projects/sourcemap/expected/file.js: -------------------------------------------------------------------------------- 1 | 'use strict';var VARS={namespace:"_some-original-namespace",container:"-container",dragging:"dragging",width:"250",height:"140"},Html=function(a){this.Base=a};Html.prototype.createContainer=function(){var a=document.createElement("div");a.className=VARS.namespace+VARS.container;a.textContent="Drag me";document.body.appendChild(a);return a};Html.prototype.htmlTest=function(){console.info("htmlTest invoked")}; 2 | 3 | -------------------------------------------------------------------------------- /src/test/resources/projects/sourcemap/expected/file.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version":3, 3 | "file":"file.js", 4 | "lineCount":1, 5 | "mappings":"A,aAwBA,IAAMA,KAAO,CACZ,UAAa,0BADD,CAEZ,UAAa,YAFD,CAGZ,SAAY,UAHA,CAIZ,MAAS,KAJG,CAKZ,OAAU,KALE,CAAb,CAQMC,KAKLC,QAAW,CAACC,CAAD,CAAO,CACjB,IAAKC,CAAAA,IAAL,CAAYD,CADK,CAOlB,KAAA,CAAA,SAAA,CAAA,eAAAE,CAAAA,QAAe,EAAG,CACjB,IAAMC,EAAYC,QAASC,CAAAA,aAAT,CAAuB,KAAvB,CAClBF,EAAUG,CAAAA,SAAV,CAAsBT,IAAKU,CAAAA,SAA3B,CAAuCV,IAAKM,CAAAA,SAC5CA,EAAUK,CAAAA,WAAV,CAAwB,SACxBJ,SAASK,CAAAA,IAAKC,CAAAA,WAAd,CAA0BP,CAA1B,CACA,OAAOA,EALU,CAQlB,KAAA,CAAA,SAAA,CAAA,QAAAQ,CAAAA,QAAQ,EAAG,CACVC,OAAQC,CAAAA,IAAR,CAAa,kBAAb,CADU;", 6 | "sources":["../../test/sample.js"], 7 | "names":["VARS","Html","constructor","base","Base","createContainer","container","document","createElement","className","namespace","textContent","body","appendChild","htmlTest","console","info"] 8 | } 9 | -------------------------------------------------------------------------------- /src/test/resources/projects/sourcemap/expected/inline.js: -------------------------------------------------------------------------------- 1 | 'use strict';var VARS={namespace:"_some-original-namespace",container:"-container",dragging:"dragging",width:"250",height:"140"},Html=function(a){this.Base=a};Html.prototype.createContainer=function(){var a=document.createElement("div");a.className=VARS.namespace+VARS.container;a.textContent="Drag me";document.body.appendChild(a);return a};Html.prototype.htmlTest=function(){console.info("htmlTest invoked")}; 2 | 3 | //# sourceMappingURL=data:application/json;charset=utf-8;base64,ewoidmVyc2lvbiI6MywKImZpbGUiOiJpbmxpbmUuanMiLAoibGluZUNvdW50IjoxLAoibWFwcGluZ3MiOiJBLGFBd0JBLElBQU1BLEtBQU8sQ0FDWixVQUFhLDBCQURELENBRVosVUFBYSxZQUZELENBR1osU0FBWSxVQUhBLENBSVosTUFBUyxLQUpHLENBS1osT0FBVSxLQUxFLENBQWIsQ0FRTUMsS0FLTEMsUUFBVyxDQUFDQyxDQUFELENBQU8sQ0FDakIsSUFBS0MsQ0FBQUEsSUFBTCxDQUFZRCxDQURLLENBT2xCLEtBQUEsQ0FBQSxTQUFBLENBQUEsZUFBQUUsQ0FBQUEsUUFBZSxFQUFHLENBQ2pCLElBQU1DLEVBQVlDLFFBQVNDLENBQUFBLGFBQVQsQ0FBdUIsS0FBdkIsQ0FDbEJGLEVBQVVHLENBQUFBLFNBQVYsQ0FBc0JULElBQUtVLENBQUFBLFNBQTNCLENBQXVDVixJQUFLTSxDQUFBQSxTQUM1Q0EsRUFBVUssQ0FBQUEsV0FBVixDQUF3QixTQUN4QkosU0FBU0ssQ0FBQUEsSUFBS0MsQ0FBQUEsV0FBZCxDQUEwQlAsQ0FBMUIsQ0FDQSxPQUFPQSxFQUxVLENBUWxCLEtBQUEsQ0FBQSxTQUFBLENBQUEsUUFBQVEsQ0FBQUEsUUFBUSxFQUFHLENBQ1ZDLE9BQVFDLENBQUFBLElBQVIsQ0FBYSxrQkFBYixDQURVOyIsCiJzb3VyY2VzIjpbIi4uLy4uL3Rlc3Qvc2FtcGxlLmpzIl0sCiJuYW1lcyI6WyJWQVJTIiwiSHRtbCIsImNvbnN0cnVjdG9yIiwiYmFzZSIsIkJhc2UiLCJjcmVhdGVDb250YWluZXIiLCJjb250YWluZXIiLCJkb2N1bWVudCIsImNyZWF0ZUVsZW1lbnQiLCJjbGFzc05hbWUiLCJuYW1lc3BhY2UiLCJ0ZXh0Q29udGVudCIsImJvZHkiLCJhcHBlbmRDaGlsZCIsImh0bWxUZXN0IiwiY29uc29sZSIsImluZm8iXQp9Cg== 4 | -------------------------------------------------------------------------------- /src/test/resources/projects/sourcemap/expected/location-mapping-empty.js: -------------------------------------------------------------------------------- 1 | 'use strict';var VARS={namespace:"_some-original-namespace",container:"-container",dragging:"dragging",width:"250",height:"140"},Html=function(a){this.Base=a};Html.prototype.createContainer=function(){var a=document.createElement("div");a.className=VARS.namespace+VARS.container;a.textContent="Drag me";document.body.appendChild(a);return a};Html.prototype.htmlTest=function(){console.info("htmlTest invoked")}; 2 | //# sourceMappingURL=location-mapping-empty.js.map 3 | -------------------------------------------------------------------------------- /src/test/resources/projects/sourcemap/expected/location-mapping-empty.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version":3, 3 | "file":"localhost://bazbar/location-mapping-empty.js", 4 | "lineCount":1, 5 | "mappings":"A,aAwBA,IAAMA,KAAO,CACZ,UAAa,0BADD,CAEZ,UAAa,YAFD,CAGZ,SAAY,UAHA,CAIZ,MAAS,KAJG,CAKZ,OAAU,KALE,CAAb,CAQMC,KAKLC,QAAW,CAACC,CAAD,CAAO,CACjB,IAAKC,CAAAA,IAAL,CAAYD,CADK,CAOlB,KAAA,CAAA,SAAA,CAAA,eAAAE,CAAAA,QAAe,EAAG,CACjB,IAAMC,EAAYC,QAASC,CAAAA,aAAT,CAAuB,KAAvB,CAClBF,EAAUG,CAAAA,SAAV,CAAsBT,IAAKU,CAAAA,SAA3B,CAAuCV,IAAKM,CAAAA,SAC5CA,EAAUK,CAAAA,WAAV,CAAwB,SACxBJ,SAASK,CAAAA,IAAKC,CAAAA,WAAd,CAA0BP,CAA1B,CACA,OAAOA,EALU,CAQlB,KAAA,CAAA,SAAA,CAAA,QAAAQ,CAAAA,QAAQ,EAAG,CACVC,OAAQC,CAAAA,IAAR,CAAa,kBAAb,CADU;", 6 | "sources":["localhost://bazbar/sample.js"], 7 | "names":["VARS","Html","constructor","base","Base","createContainer","container","document","createElement","className","namespace","textContent","body","appendChild","htmlTest","console","info"] 8 | } 9 | -------------------------------------------------------------------------------- /src/test/resources/projects/sourcemap/expected/location-mapping.js: -------------------------------------------------------------------------------- 1 | 'use strict';var VARS={namespace:"_some-original-namespace",container:"-container",dragging:"dragging",width:"250",height:"140"},Html=function(a){this.Base=a};Html.prototype.createContainer=function(){var a=document.createElement("div");a.className=VARS.namespace+VARS.container;a.textContent="Drag me";document.body.appendChild(a);return a};Html.prototype.htmlTest=function(){console.info("htmlTest invoked")}; 2 | 3 | //# sourceMappingURL=location-mapping.js.map 4 | -------------------------------------------------------------------------------- /src/test/resources/projects/sourcemap/expected/location-mapping.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version":3, 3 | "file":"location-mapping.js", 4 | "lineCount":1, 5 | "mappings":"A,aAwBA,IAAMA,KAAO,CACZ,UAAa,0BADD,CAEZ,UAAa,YAFD,CAGZ,SAAY,UAHA,CAIZ,MAAS,KAJG,CAKZ,OAAU,KALE,CAAb,CAQMC,KAKLC,QAAW,CAACC,CAAD,CAAO,CACjB,IAAKC,CAAAA,IAAL,CAAYD,CADK,CAOlB,KAAA,CAAA,SAAA,CAAA,eAAAE,CAAAA,QAAe,EAAG,CACjB,IAAMC,EAAYC,QAASC,CAAAA,aAAT,CAAuB,KAAvB,CAClBF,EAAUG,CAAAA,SAAV,CAAsBT,IAAKU,CAAAA,SAA3B,CAAuCV,IAAKM,CAAAA,SAC5CA,EAAUK,CAAAA,WAAV,CAAwB,SACxBJ,SAASK,CAAAA,IAAKC,CAAAA,WAAd,CAA0BP,CAA1B,CACA,OAAOA,EALU,CAQlB,KAAA,CAAA,SAAA,CAAA,QAAAQ,CAAAA,QAAQ,EAAG,CACVC,OAAQC,CAAAA,IAAR,CAAa,kBAAb,CADU;", 6 | "sources":["localhost://foobar/sample.js"], 7 | "names":["VARS","Html","constructor","base","Base","createContainer","container","document","createElement","className","namespace","textContent","body","appendChild","htmlTest","console","info"] 8 | } 9 | -------------------------------------------------------------------------------- /src/test/resources/projects/sourcemap/expected/map-path.js: -------------------------------------------------------------------------------- 1 | 'use strict';var VARS={namespace:"_some-original-namespace",container:"-container",dragging:"dragging",width:"250",height:"140"},Html=function(a){this.Base=a};Html.prototype.createContainer=function(){var a=document.createElement("div");a.className=VARS.namespace+VARS.container;a.textContent="Drag me";document.body.appendChild(a);return a};Html.prototype.htmlTest=function(){console.info("htmlTest invoked")}; 2 | 3 | //# sourceMappingURL=sourcemap/map-path.js.map 4 | -------------------------------------------------------------------------------- /src/test/resources/projects/sourcemap/expected/reference.js: -------------------------------------------------------------------------------- 1 | 'use strict';var VARS={namespace:"_some-original-namespace",container:"-container",dragging:"dragging",width:"250",height:"140"},Html=function(a){this.Base=a};Html.prototype.createContainer=function(){var a=document.createElement("div");a.className=VARS.namespace+VARS.container;a.textContent="Drag me";document.body.appendChild(a);return a};Html.prototype.htmlTest=function(){console.info("htmlTest invoked")}; 2 | 3 | //# sourceMappingURL=reference.js.map 4 | -------------------------------------------------------------------------------- /src/test/resources/projects/sourcemap/expected/reference.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version":3, 3 | "file":"reference.js", 4 | "lineCount":1, 5 | "mappings":"A,aAwBA,IAAMA,KAAO,CACZ,UAAa,0BADD,CAEZ,UAAa,YAFD,CAGZ,SAAY,UAHA,CAIZ,MAAS,KAJG,CAKZ,OAAU,KALE,CAAb,CAQMC,KAKLC,QAAW,CAACC,CAAD,CAAO,CACjB,IAAKC,CAAAA,IAAL,CAAYD,CADK,CAOlB,KAAA,CAAA,SAAA,CAAA,eAAAE,CAAAA,QAAe,EAAG,CACjB,IAAMC,EAAYC,QAASC,CAAAA,aAAT,CAAuB,KAAvB,CAClBF,EAAUG,CAAAA,SAAV,CAAsBT,IAAKU,CAAAA,SAA3B,CAAuCV,IAAKM,CAAAA,SAC5CA,EAAUK,CAAAA,WAAV,CAAwB,SACxBJ,SAASK,CAAAA,IAAKC,CAAAA,WAAd,CAA0BP,CAA1B,CACA,OAAOA,EALU,CAQlB,KAAA,CAAA,SAAA,CAAA,QAAAQ,CAAAA,QAAQ,EAAG,CACVC,OAAQC,CAAAA,IAAR,CAAa,kBAAb,CADU;", 6 | "sources":["../../test/sample.js"], 7 | "names":["VARS","Html","constructor","base","Base","createContainer","container","document","createElement","className","namespace","textContent","body","appendChild","htmlTest","console","info"] 8 | } 9 | -------------------------------------------------------------------------------- /src/test/resources/projects/sourcemap/expected/sourcemap/map-path.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version":3, 3 | "file":"../map-path.js", 4 | "lineCount":1, 5 | "mappings":"A,aAwBA,IAAMA,KAAO,CACZ,UAAa,0BADD,CAEZ,UAAa,YAFD,CAGZ,SAAY,UAHA,CAIZ,MAAS,KAJG,CAKZ,OAAU,KALE,CAAb,CAQMC,KAKLC,QAAW,CAACC,CAAD,CAAO,CACjB,IAAKC,CAAAA,IAAL,CAAYD,CADK,CAOlB,KAAA,CAAA,SAAA,CAAA,eAAAE,CAAAA,QAAe,EAAG,CACjB,IAAMC,EAAYC,QAASC,CAAAA,aAAT,CAAuB,KAAvB,CAClBF,EAAUG,CAAAA,SAAV,CAAsBT,IAAKU,CAAAA,SAA3B,CAAuCV,IAAKM,CAAAA,SAC5CA,EAAUK,CAAAA,WAAV,CAAwB,SACxBJ,SAASK,CAAAA,IAAKC,CAAAA,WAAd,CAA0BP,CAA1B,CACA,OAAOA,EALU,CAQlB,KAAA,CAAA,SAAA,CAAA,QAAAQ,CAAAA,QAAQ,EAAG,CACVC,OAAQC,CAAAA,IAAR,CAAa,kBAAb,CADU;", 6 | "sources":["../../../test/sample.js"], 7 | "names":["VARS","Html","constructor","base","Base","createContainer","container","document","createElement","className","namespace","textContent","body","appendChild","htmlTest","console","info"] 8 | } 9 | -------------------------------------------------------------------------------- /src/test/resources/projects/sourcemap/test/sample.js: -------------------------------------------------------------------------------- 1 | /* https://github.com/jonataswalker/es6-sample-project */ 2 | /* 3 | The MIT License (MIT) 4 | 5 | Copyright (c) 2016 Jonatas Walker 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | */ 25 | const VARS = { 26 | "namespace": "_some-original-namespace", 27 | "container": "-container", 28 | "dragging": "dragging", 29 | "width": "250", 30 | "height": "140" 31 | }; 32 | 33 | class Html { 34 | /** 35 | * @constructor 36 | * @param {new (...args: any[]) => any} base Base class. 37 | */ 38 | constructor(base) { 39 | this.Base = base; 40 | } 41 | 42 | /** 43 | * @returns {HTMLDivElement} 44 | */ 45 | createContainer() { 46 | const container = document.createElement('div'); 47 | container.className = VARS.namespace + VARS.container; 48 | container.textContent = 'Drag me'; 49 | document.body.appendChild(container); 50 | return container; 51 | } 52 | 53 | htmlTest() { 54 | console.info('htmlTest invoked'); // eslint-disable-line no-console 55 | } 56 | } -------------------------------------------------------------------------------- /src/test/resources/projects/sourcemap/test2/js/sample.js: -------------------------------------------------------------------------------- 1 | /* https://github.com/jonataswalker/es6-sample-project */ 2 | /* 3 | The MIT License (MIT) 4 | 5 | Copyright (c) 2016 Jonatas Walker 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | */ 25 | const VARS = { 26 | "namespace": "_some-original-namespace", 27 | "container": "-container", 28 | "dragging": "dragging", 29 | "width": "250", 30 | "height": "140" 31 | }; 32 | 33 | class Html { 34 | /** 35 | * @constructor 36 | * @param {new (...args: any[]) => any} base Base class. 37 | */ 38 | constructor(base) { 39 | this.Base = base; 40 | } 41 | 42 | /** 43 | * @returns {HTMLDivElement} 44 | */ 45 | createContainer() { 46 | const container = document.createElement('div'); 47 | container.className = VARS.namespace + VARS.container; 48 | container.textContent = 'Drag me'; 49 | document.body.appendChild(container); 50 | return container; 51 | } 52 | 53 | htmlTest() { 54 | console.info('htmlTest invoked'); // eslint-disable-line no-console 55 | } 56 | } -------------------------------------------------------------------------------- /src/test/resources/projects/subdirs/expected/resources/js/f1/file1.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';console.log("file1"); -------------------------------------------------------------------------------- /src/test/resources/projects/subdirs/expected/resources/js/f1/file2.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';console.log("file2"); -------------------------------------------------------------------------------- /src/test/resources/projects/subdirs/expected/resources/js/f1/file3.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';console.log("file3"); -------------------------------------------------------------------------------- /src/test/resources/projects/subdirs/expected/resources/scripts/file4.min.js: -------------------------------------------------------------------------------- 1 | 'use strict';console.log("file4"); -------------------------------------------------------------------------------- /src/test/resources/projects/subdirs/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 4.0.0 8 | com.github.blutorange 9 | closure-compiler-maven-plugin-test-subdirs 10 | 1.0-SNAPSHOT 11 | jar 12 | 13 | com.github.blutorange 14 | closure-compiler-maven-plugin-test 15 | 1.0-SNAPSHOT 16 | .. 17 | 18 | 19 | 20 | 21 | 22 | com.github.blutorange 23 | closure-compiler-maven-plugin 24 | 25 | ${project.basedir} 26 | ${project.build.directory} 27 | true 28 | 29 | resources/js/**/*.js 30 | resources/scripts/*.js 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/test/resources/projects/subdirs/test/resources/js/f1/file1.js: -------------------------------------------------------------------------------- 1 | console.log("file1"); -------------------------------------------------------------------------------- /src/test/resources/projects/subdirs/test/resources/js/f1/file2.js: -------------------------------------------------------------------------------- 1 | console.log("file2"); -------------------------------------------------------------------------------- /src/test/resources/projects/subdirs/test/resources/js/f1/file3.js: -------------------------------------------------------------------------------- 1 | console.log("file3"); -------------------------------------------------------------------------------- /src/test/resources/projects/subdirs/test/resources/scripts/file4.js: -------------------------------------------------------------------------------- 1 | console.log("file4"); -------------------------------------------------------------------------------- /src/test/resources/projects/trustedstrings/expected/trusted-false.js: -------------------------------------------------------------------------------- 1 | 'use strict';const div=document.createElement("div");div.innerHTML='\n\t\x3cform\x3e\n\t \x3clabel for\x3d"answer"\x3eIf x \x26lt; 10 + 2 \x26gt; z, find the value of R!\x3c/label\x3e\n\t \x3cinput id\x3d"answer" type\x3d"number" value\x3d"42"\x3e\n\t\x3c/form\x3e\n';document.body.appendChild(div); -------------------------------------------------------------------------------- /src/test/resources/projects/trustedstrings/expected/trusted-true.js: -------------------------------------------------------------------------------- 1 | 'use strict';const div=document.createElement("div");div.innerHTML='\n\t
\n\t \n\t \n\t
\n';document.body.appendChild(div); -------------------------------------------------------------------------------- /src/test/resources/projects/trustedstrings/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 4.0.0 6 | com.github.blutorange 7 | closure-compiler-maven-plugin-test-minimal 8 | 1.0-SNAPSHOT 9 | jar 10 | 11 | com.github.blutorange 12 | closure-compiler-maven-plugin-test 13 | 1.0-SNAPSHOT 14 | .. 15 | 16 | 17 | 18 | 19 | 20 | com.github.blutorange 21 | closure-compiler-maven-plugin 22 | 23 | ${project.basedir} 24 | ${project.build.directory} 25 | 26 | 27 | 28 | default-minify 29 | generate-resources 30 | 31 | minify 32 | 33 | 34 | true 35 | trusted-true.js 36 | 37 | 38 | 39 | trusted-strings 40 | generate-resources 41 | 42 | minify 43 | 44 | 45 | false 46 | trusted-false.js 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/test/resources/projects/trustedstrings/test/hello.js: -------------------------------------------------------------------------------- 1 | const div = document.createElement("div"); 2 | div.innerHTML = ` 3 |
4 | 5 | 6 |
7 | `; 8 | document.body.appendChild(div); -------------------------------------------------------------------------------- /src/test/resources/projects/usetypesforoptimization/expected/script.js: -------------------------------------------------------------------------------- 1 | 'use strict';class a{g(){console.log(1)}}class b{g(){console.log(2)}}console.log(a,b);(new a).g(); -------------------------------------------------------------------------------- /src/test/resources/projects/usetypesforoptimization/expected/script.optim.js: -------------------------------------------------------------------------------- 1 | 'use strict';class a{}class b{}console.log(a,b);console.log(1); 2 | 3 | -------------------------------------------------------------------------------- /src/test/resources/projects/usetypesforoptimization/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | com.github.blutorange 8 | closure-compiler-maven-plugin-test-emitusestrict 9 | 1.0-SNAPSHOT 10 | jar 11 | 12 | com.github.blutorange 13 | closure-compiler-maven-plugin-test 14 | 1.0-SNAPSHOT 15 | .. 16 | 17 | 18 | 19 | 20 | 21 | com.github.blutorange 22 | closure-compiler-maven-plugin 23 | 24 | ${project.basedir} 25 | ${project.build.directory} 26 | 27 | 28 | 29 | 30 | default-minify 31 | generate-resources 32 | 33 | minify 34 | 35 | 36 | ADVANCED_OPTIMIZATIONS 37 | false 38 | script.js 39 | 40 | 41 | 42 | use-types-for-optimization 43 | generate-resources 44 | 45 | minify 46 | 47 | 48 | ADVANCED_OPTIMIZATIONS 49 | true 50 | script.optim.js 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/test/resources/projects/usetypesforoptimization/test/script.js: -------------------------------------------------------------------------------- 1 | class Foo1 { 2 | foo() { 3 | console.log(1); 4 | } 5 | } 6 | 7 | class Foo2 { 8 | foo() { 9 | console.log(2); 10 | } 11 | } 12 | 13 | console.log(Foo1, Foo2); 14 | 15 | /** @type {Foo1} */ 16 | const x = new Foo1(); 17 | 18 | x.foo(); 19 | --------------------------------------------------------------------------------