Skip to content
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
22 changes: 22 additions & 0 deletions mycore-sass/src/main/java/org/mycore/sass/MCRSassCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -79,6 +81,8 @@ class MCRSassCompiler implements Closeable {

private boolean emitCharset;

private List<String> silenceDeprecations;

private final CompilerConnection connection;

private static final AtomicInteger COMPILE_REQUEST_IDS = new AtomicInteger();
Expand All @@ -96,12 +100,29 @@ class MCRSassCompiler implements Closeable {
this.quietDeps = false;
this.sourceMapIncludeSources = false;
this.emitCharset = false;
this.silenceDeprecations = new ArrayList<>();
this.customImporters = new HashMap<>();
this.loggingHandler = new Log4jLoggingHandler(LOGGER);
this.connection = connection;

}

public boolean isQuietDeps() {
return quietDeps;
}

public void setQuietDeps(boolean quietDeps) {
this.quietDeps = quietDeps;
}

public List<String> getSilenceDeprecations() {
return silenceDeprecations;
}

public void setSilenceDeprecations(List<String> silenceDeprecations) {
this.silenceDeprecations = silenceDeprecations;
}

protected CompileRequest.Builder compileRequestBuilder() {
CompileRequest.Builder builder = CompileRequest.newBuilder();

Expand All @@ -121,6 +142,7 @@ protected CompileRequest.Builder compileRequestBuilder() {
builder.setQuietDeps(quietDeps);
builder.setSourceMapIncludeSources(sourceMapIncludeSources);
builder.setCharset(emitCharset);
builder.addAllSilenceDeprecation(silenceDeprecations);
return builder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public final class MCRSassCompilerManager {

private static final String DEVELOPER_MODE_CONFIG_KEY = "MCR.SASS.DeveloperMode";

private static final String SASS_QUIET_DEPS = "MCR.SASS.QuietDeps";

private static final String SASS_SILENCE_DEPRECATIONS = "MCR.SASS.SilenceDeprecations";

private final Map<String, String> fileCompiledContentMap = new ConcurrentHashMap<>();

private final Map<String, Date> fileLastCompileDateMap = new ConcurrentHashMap<>();
Expand Down Expand Up @@ -106,6 +110,11 @@ private String compile(String name)
throws IOException, SassCompilationFailedException {
String css;
try (MCRSassCompiler sassCompiler = new MCRSassCompiler(ConnectionFactory.bundled())) {
sassCompiler.setQuietDeps(MCRConfiguration2.getBoolean(SASS_QUIET_DEPS)
.orElseThrow(() -> MCRConfiguration2.createConfigurationException(SASS_QUIET_DEPS)));
sassCompiler.setSilenceDeprecations(
MCRConfiguration2.getOrThrow(SASS_SILENCE_DEPRECATIONS, MCRConfiguration2::splitValue)
.toList());
String realFileName = getRealFileName(name);
var compileSuccess = sassCompiler.compile(realFileName);
css = compileSuccess.getCss();
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
MCR.Jersey.Resource.Packages=%MCR.Jersey.Resource.Packages%,org.mycore.sass.resources

MCR.SASS.QuietDeps=true
MCR.SASS.SilenceDeprecations=import
Loading