diff --git a/pom.xml b/pom.xml index 7daf9268..9ca7e1b8 100644 --- a/pom.xml +++ b/pom.xml @@ -199,21 +199,6 @@ plexus-interpolation 1.27 - - com.fasterxml.jackson.core - jackson-core - 2.16.2 - - - com.fasterxml.jackson.core - jackson-databind - 2.16.2 - - - com.google.guava - guava - 32.1.2-jre - junit diff --git a/src/main/java/org/codehaus/mojo/flatten/FlattenDescriptor.java b/src/main/java/org/codehaus/mojo/flatten/FlattenDescriptor.java index 56f6f4c0..64abffee 100644 --- a/src/main/java/org/codehaus/mojo/flatten/FlattenDescriptor.java +++ b/src/main/java/org/codehaus/mojo/flatten/FlattenDescriptor.java @@ -19,10 +19,10 @@ * under the License. */ +import java.util.Collections; import java.util.HashMap; import java.util.Map; -import com.google.common.collect.ImmutableMap; import org.apache.maven.model.Build; import org.apache.maven.model.Model; import org.codehaus.plexus.util.xml.Xpp3Dom; @@ -46,8 +46,8 @@ public FlattenDescriptor() { this.name2handlingMap = new HashMap<>(); } - public ImmutableMap getName2handlingMap() { - return ImmutableMap.copyOf(name2handlingMap); + public Map getName2handlingMap() { + return Collections.unmodifiableMap(name2handlingMap); } /** diff --git a/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java b/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java index f9f90262..a7ae9414 100644 --- a/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java +++ b/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java @@ -48,9 +48,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.collect.ImmutableList; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; @@ -456,24 +453,35 @@ protected boolean shouldSkipGoal() { private void logParameters() { - try { - getLog().info("Generating flattened POM of project " + this.project.getId() + " with following parameters " - + new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this.getParameters())); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); + getLog().info("Generating flattened POM of project " + this.project.getId() + " with following parameters " + + this.asString(this.getParameters())); + } + + private String asString(Map map) { + final StringBuilder stringBuilder = new StringBuilder("{"); + int i = 0; + for (Map.Entry entry : map.entrySet()) { + if (i > 0) { + stringBuilder.append(", "); + } + stringBuilder + .append(entry.getKey()) + .append("='") + .append(entry.getValue()) + .append("'"); + i++; } + stringBuilder.append(" }"); + return stringBuilder.toString(); } private Map getParameters() { - final Map parameters = new HashMap<>(); + final List fields = new ArrayList<>(Arrays.asList(this.getClass().getDeclaredFields())); + fields.addAll(Arrays.asList(this.getClass().getSuperclass().getDeclaredFields())); - final ImmutableList.Builder fieldsBuilder = ImmutableList.builder(); - Arrays.stream(this.getClass().getDeclaredFields()).forEach(fieldsBuilder::add); - Arrays.stream(this.getClass().getSuperclass().getDeclaredFields()).forEach(fieldsBuilder::add); - fieldsBuilder.build().stream() - .sorted(Comparator.comparing(Field::getName)) - .forEach(field -> putValue(parameters, field)); + final Map parameters = new HashMap<>(); + fields.stream().sorted(Comparator.comparing(Field::getName)).forEach(field -> putValue(parameters, field)); return parameters; }