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

Make more compatible with JPMS #154

Merged
merged 1 commit into from
Jul 27, 2024
Merged
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
11 changes: 9 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
<groupId>org.webjars.npm</groupId>
<artifactId>js-beautify</artifactId>
<version>1.14.7</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.openjdk.nashorn</groupId>
Expand Down Expand Up @@ -155,6 +161,7 @@
</Service-Component>
<Bundle-RequiredExecutionEnvironment>JavaSE-1.6
</Bundle-RequiredExecutionEnvironment>
<Automatic-Module-Name>org.javadelight.nashornsandbox</Automatic-Module-Name>
</instructions>
</configuration>
</plugin>
Expand All @@ -171,11 +178,11 @@
<goal>run</goal>
</goals>
<configuration>
<tasks>
<target>
<delete file="${basedir}/META-INF/MANIFEST.MF" />
<copy file="target/classes/META-INF/MANIFEST.MF"
tofile="${basedir}/META-INF/MANIFEST.MF" />
</tasks>
</target>
</configuration>
</execution>
</executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private static class PoisonPil {
}

/** The resource name of beautify.min.js script. */
private final static String BEAUTIFY_JS = "/META-INF/resources/webjars/js-beautify/1.14.7/js/lib/beautifier.js";
private final static String BEAUTIFY_JS = "META-INF/resources/webjars/js-beautify/1.14.7/js/lib/beautifier.js";

/** The beautify function search list. */
private static final List<String> BEAUTIFY_FUNCTIONS = Arrays.asList("exports.beautifier.js;", "window.js_beautify;", "exports.js_beautify;",
Expand Down Expand Up @@ -299,7 +299,8 @@ private static String getBeautifyJs() {
String script = beautifysScript.get();
if (script == null) {
try (final BufferedReader reader = new BufferedReader(new InputStreamReader(
new BufferedInputStream(JsSanitizer.class.getResourceAsStream(BEAUTIFY_JS)), StandardCharsets.UTF_8))) {
new BufferedInputStream(JsSanitizer.class.getClassLoader().getResourceAsStream(BEAUTIFY_JS)),
StandardCharsets.UTF_8))) {
final StringBuilder sb = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
Expand All @@ -317,7 +318,7 @@ private static String getBeautifyJs() {

@SuppressWarnings("unchecked")
private static Function<String, String> beautifierAsFunction(Object beautifyScript) {

if (NashornDetection.isStandaloneNashornScriptObjectMirror(beautifyScript)) {
return script -> {
org.openjdk.nashorn.api.scripting.ScriptObjectMirror scriptObjectMirror = (org.openjdk.nashorn.api.scripting.ScriptObjectMirror) beautifyScript;
Expand Down