diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/BinarizeMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/BinarizeMojo.java index 66a9042a55..23e92fec4a 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/BinarizeMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/BinarizeMojo.java @@ -61,24 +61,7 @@ public final class BinarizeMojo extends SafeMojo { /** * Name of executable file which is result of cargo building. */ - public static final String LIB; - - static { - if (SystemUtils.IS_OS_WINDOWS) { - LIB = "common.dll"; - } else if (SystemUtils.IS_OS_LINUX) { - LIB = "libcommon.so"; - } else if (SystemUtils.IS_OS_MAC) { - LIB = "libcommon.dylib"; - } else { - throw new IllegalArgumentException( - String.format( - "Rust inserts are not supported in %s os. Only windows, linux and macos are allowed.", - System.getProperty("os.name") - ) - ); - } - } + public static final String LIB = BinarizeMojo.common(); /** * The directory where to binarize to. @@ -130,6 +113,29 @@ public void exec() throws IOException { Logger.info(this, "Built in total %d cargo projects", total); } + /** + * Calculates name for Rust shared library depending on OS. + * @return Name. + */ + private static String common() { + final String result; + if (SystemUtils.IS_OS_WINDOWS) { + result = "common.dll"; + } else if (SystemUtils.IS_OS_LINUX) { + result = "libcommon.so"; + } else if (SystemUtils.IS_OS_MAC) { + result = "libcommon.dylib"; + } else { + throw new IllegalArgumentException( + String.format( + "Rust inserts are not supported in %s os. Only windows, linux and macos are allowed.", + System.getProperty("os.name") + ) + ); + } + return result; + } + /** * Is the project valid? * @param project File to check.