List<String> (@NotNull List<String> commandLineArguments) { List<String> replaced = new ArrayList<>(commandLineArguments.size()); final String PASSWORD_PARAMETER_IDENTIFIER = ".password="; for (String option : commandLineArguments) { // Find parameters ending in "password", like: // -Pandroid.injected.signing.store.password= // -Pandroid.injected.signing.key.password= int index = option.indexOf(PASSWORD_PARAMETER_IDENTIFIER); if (index == -1) { replaced.add(option); } else { replaced.add(option.substring(0, index + PASSWORD_PARAMETER_IDENTIFIER.length()) + "*********"); } } return replaced; }