diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..8eec0db --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,17 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +- New feature to autodetect Linux Musl systems and use the Musl version of the +binary if detected + +### Removed + +- Cascade-remove support for Windows 7 and 8 as per https://github.com/dart-lang/sdk/issues/54509 diff --git a/README.md b/README.md index 387930c..32170e0 100644 --- a/README.md +++ b/README.md @@ -97,9 +97,6 @@ This parameter represents the Dart Sass operating system that should be used to **Type**: String
**Required**: No -> [!WARNING] -> When compiling on alpine derived images, setting `os` to `linux-musl` is required as it cannot be autodetected. - `` This parameter represents the Dart Sass version that should be used to compile Sass files. If left unset, the version available at https://github.com/sass/dart-sass/releases/latest will be used.
diff --git a/pom.xml b/pom.xml index 1762f3c..30e5975 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ io.github.cleydyr dart-sass-maven-plugin maven-plugin - 1.3.1-SNAPSHOT + 1.4.0-SNAPSHOT dart-sass-maven-plugin Maven Mojo A Maven plugin that allows to compile SASS using Dart Sass @@ -29,8 +29,8 @@ 1.8 1.8 2.43.0 - 3.9.6 - 3.11.0 + 3.9.8 + 3.12.0 UTF-8 @@ -67,19 +67,19 @@ org.mockito mockito-core - 5.10.0 + 5.11.0 test org.junit.jupiter junit-jupiter - 5.10.2 + 5.10.3 test org.apache.httpcomponents.client5 httpclient5-fluent - 5.3.1 + 5.4 org.apache.commons @@ -89,7 +89,7 @@ org.kohsuke github-api - 1.321 + 1.326 diff --git a/src/main/java/com/github/cleydyr/dart/system/OSDetector.java b/src/main/java/com/github/cleydyr/dart/system/OSDetector.java index e653c37..81923b3 100644 --- a/src/main/java/com/github/cleydyr/dart/system/OSDetector.java +++ b/src/main/java/com/github/cleydyr/dart/system/OSDetector.java @@ -1,6 +1,9 @@ package com.github.cleydyr.dart.system; import com.github.cleydyr.dart.system.exception.OSDetectionException; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -59,6 +62,10 @@ private OSDetector() { DETECTED_OS = OS_WINDOWS; IS_WINDOWS = true; + } else if (isLinuxMusl()) { + DETECTED_OS = OS_LINUX_WITH_MUSL; + + IS_WINDOWS = false; } else { DETECTED_OS = OS_LINUX; @@ -101,4 +108,27 @@ public static boolean isAcceptedOSName(String osName) { public static boolean isAcceptedArchitecture(String architecture) { return ACCEPTED_ARCHITECTURES.stream().anyMatch(architecture::equals); } + + public static boolean isLinuxMusl() { + try { + ProcessBuilder processBuilder = new ProcessBuilder("ldd", "--version"); + + Process process = processBuilder.start(); + + InputStream inputStream = process.getErrorStream(); + + try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { + boolean hasMusl = reader.lines().anyMatch(line -> line.contains("musl")); + + process.waitFor(); + + return hasMusl; + } + } catch (Exception e) { + // TODO: log warning + e.printStackTrace(); + } + + return false; + } } diff --git a/src/test/resources/musl/test-project/pom.xml b/src/test/resources/musl/test-project/pom.xml index b8a048a..4f003a3 100644 --- a/src/test/resources/musl/test-project/pom.xml +++ b/src/test/resources/musl/test-project/pom.xml @@ -5,7 +5,7 @@ com.github.cleydyr test-project - 1.3.1-SNAPSHOT + 1.4.0-SNAPSHOT test-project A simple test-project. @@ -21,12 +21,11 @@ io.github.cleydyr dart-sass-maven-plugin - 1.3.1-SNAPSHOT + 1.4.0-SNAPSHOT ${project.build.directory}/static/styles - 1.71.1 - linux-musl + 1.79.3 diff --git a/src/test/resources/test-project/pom.xml b/src/test/resources/test-project/pom.xml index 1727741..4f003a3 100644 --- a/src/test/resources/test-project/pom.xml +++ b/src/test/resources/test-project/pom.xml @@ -5,7 +5,7 @@ com.github.cleydyr test-project - 1.3.1-SNAPSHOT + 1.4.0-SNAPSHOT test-project A simple test-project. @@ -21,11 +21,11 @@ io.github.cleydyr dart-sass-maven-plugin - 1.3.1-SNAPSHOT + 1.4.0-SNAPSHOT ${project.build.directory}/static/styles - 1.71.1 + 1.79.3