Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES6+ support #173

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.samaxes.maven</groupId>
<artifactId>minify-maven-plugin</artifactId>
<version>2.0.0-SNAPSHOT</version>
<version>2.0.0</version>
<packaging>maven-plugin</packaging>

<name>Minify Maven Plugin</name>
Expand Down Expand Up @@ -82,13 +82,13 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.3.9</version>
<version>3.6.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.5</version>
<version>3.6.0</version>
<scope>provided</scope>
</dependency>
<!-- Compile -->
Expand All @@ -101,13 +101,13 @@
<dependency>
<groupId>com.google.javascript</groupId>
<artifactId>closure-compiler</artifactId>
<version>v20161024</version>
<version>v20210302</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
<version>2.8.6</version>
<optional>true</optional>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
*/
package com.samaxes.maven.minify.common;

import com.google.common.base.Strings;
import com.google.javascript.jscomp.*;
import com.google.javascript.jscomp.CompilerOptions.LanguageMode;
import com.google.javascript.jscomp.SourceMap.Format;
import com.google.javascript.jscomp.jarjar.com.google.common.base.Strings;

import java.util.HashMap;
import java.util.List;
Expand Down
20 changes: 9 additions & 11 deletions src/main/java/com/samaxes/maven/minify/plugin/MinifyMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
*/
package com.samaxes.maven.minify.plugin;

import com.google.common.base.Strings;
import com.google.gson.Gson;
import com.google.javascript.jscomp.*;
import com.google.javascript.jscomp.CompilerOptions.LanguageMode;
import com.google.javascript.jscomp.jarjar.com.google.common.base.Strings;
import com.google.javascript.jscomp.jarjar.com.google.common.collect.Lists;
import com.samaxes.maven.minify.common.Aggregation;
import com.samaxes.maven.minify.common.AggregationConfiguration;
import com.samaxes.maven.minify.common.ClosureConfig;
Expand All @@ -41,8 +42,6 @@
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import static com.google.common.collect.Lists.newArrayList;

/**
* Goal for combining and minifying CSS and JavaScript files.
*/
Expand Down Expand Up @@ -260,7 +259,7 @@ public enum Engine {
*
* @since 1.6
*/
@Parameter(property = "jsEngine", defaultValue = "YUI")
@Parameter(property = "jsEngine", defaultValue = "CLOSURE")
private Engine jsEngine;

/* *************************** */
Expand Down Expand Up @@ -312,7 +311,7 @@ public enum Engine {
*
* @since 1.7.2
*/
@Parameter(property = "closureLanguageIn", defaultValue = "ECMASCRIPT6")
@Parameter(property = "closureLanguageIn", defaultValue = "ECMASCRIPT_2020")
private LanguageMode closureLanguageIn;

/**
Expand Down Expand Up @@ -488,18 +487,17 @@ private YuiConfig fillYuiConfig() {
}

private ClosureConfig fillClosureConfig() throws MojoFailureException {
DependencyOptions dependencyOptions = new DependencyOptions();
dependencyOptions.setDependencySorting(closureSortDependencies);

DependencyOptions dependencyOptions = closureSortDependencies
? DependencyOptions.sortOnly()
: DependencyOptions.none();
List<SourceFile> externs = new ArrayList<>();
for (String extern : closureExterns) {
externs.add(SourceFile.fromFile(webappSourceDir + File.separator + extern, Charset.forName(charset)));
}

Map<DiagnosticGroup, CheckLevel> warningLevels = new HashMap<>();
DiagnosticGroups diagnosticGroups = new DiagnosticGroups();
for (Map.Entry<String, String> warningLevel : closureWarningLevels.entrySet()) {
DiagnosticGroup diagnosticGroup = diagnosticGroups.forName(warningLevel.getKey());
DiagnosticGroup diagnosticGroup = DiagnosticGroups.forName(warningLevel.getKey());
if (diagnosticGroup == null) {
throw new MojoFailureException("Failed to process closureWarningLevels: " + warningLevel.getKey() + " is an invalid DiagnosticGroup");
}
Expand All @@ -519,7 +517,7 @@ private ClosureConfig fillClosureConfig() throws MojoFailureException {

private Collection<ProcessFilesTask> createTasks(YuiConfig yuiConfig, ClosureConfig closureConfig)
throws MojoFailureException, FileNotFoundException {
List<ProcessFilesTask> tasks = newArrayList();
List<ProcessFilesTask> tasks = Lists.newArrayList();

if (!Strings.isNullOrEmpty(bundleConfiguration)) { // If a bundleConfiguration is defined, attempt to use that
AggregationConfiguration aggregationConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
*/
package com.samaxes.maven.minify.plugin;

import com.google.common.collect.Lists;
import com.google.javascript.jscomp.*;
import com.google.javascript.jscomp.Compiler;
import com.google.javascript.jscomp.jarjar.com.google.common.collect.ImmutableList;
import com.google.javascript.jscomp.jarjar.com.google.common.collect.Lists;
import com.samaxes.maven.minify.common.ClosureConfig;
import com.samaxes.maven.minify.common.JavaScriptErrorReporter;
import com.samaxes.maven.minify.common.YuiConfig;
Expand Down Expand Up @@ -137,8 +138,8 @@ protected void minify(File mergedFile, File minifiedFile) throws IOException {
compiler.compile(externs, Lists.newArrayList(input), options);

// Check for errors.
JSError[] errors = compiler.getErrors();
if (errors.length > 0) {
ImmutableList<JSError> errors = compiler.getErrors();
if (errors.size() > 0) {
StringBuilder msg = new StringBuilder("JSCompiler errors\n");
MessageFormatter formatter = new LightweightMessageFormatter(compiler);
for (JSError e : errors) {
Expand Down