MavenConfig (@NotNull String baseDir) { Options options = new Options(); for (MavenConfigSettings value : MavenConfigSettings.values()) { options.addOption(value.toOption()); } File configFile = new File(baseDir, MavenConstants.MAVEN_CONFIG_RELATIVE_PATH); List<String> configArgs = new ArrayList<>(); try { if (configFile.isFile()) { for (String arg : Files.readString(configFile.toPath(), Charset.defaultCharset()).split("\\s+")) { if (!arg.isEmpty()) { configArgs.add(arg); } } String[] cleanArgs = CleanArgument.cleanArgs(ArrayUtil.toStringArray(configArgs)); CommandLineParser parser = new GnuParser(); CommandLine parse = parser.parse(options, cleanArgs, true); return new MavenConfig(Arrays.stream(parse.getOptions()).collect(Collectors.toMap(o -> o.getOpt(), Function.identity())), baseDir); } } catch (Exception e) { MavenLog.LOG.error("error read maven config " + configFile.getAbsolutePath(), e); } return null; }