Skip to content

Commit df0b23d

Browse files
cstamasrohanKanojia
authored andcommitted
Smaller fixes
1 parent cb193d7 commit df0b23d

File tree

6 files changed

+12
-18
lines changed

6 files changed

+12
-18
lines changed

src/main/java/io/fabric8/maven/docker/AbstractDockerMojo.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import java.io.File;
44
import java.io.IOException;
5-
import java.util.Date;
5+
import java.util.ArrayList;
66
import java.util.Collections;
7+
import java.util.Date;
78
import java.util.List;
8-
import java.util.ArrayList;
99
import java.util.Map;
1010
import java.util.Properties;
1111
import java.util.regex.Matcher;

src/main/java/io/fabric8/maven/docker/StopMojo.java

-5
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,6 @@ public void execute() throws MojoExecutionException, MojoFailureException {
9898
// HttpDelete class is not used during start mojo, so we need to load it and initialize it. It is not
9999
// possible to load classes in the shutdown hook as
100100
Class.forName("org.apache.http.client.methods.HttpDelete", true, this.getClass().getClassLoader());
101-
102-
// com.google.common.base.Strings class from com.google.guava is required and it depends on Platforms
103-
// Used in @see io.fabric8.maven.docker.util.ImageNameFormatter
104-
Class.forName("com.google.common.base.Strings", true, this.getClass().getClassLoader());
105-
Class.forName("com.google.common.base.Platform", true, this.getClass().getClassLoader());
106101
} catch (ClassNotFoundException e) {
107102
log.error("Failure in loading org.apache.http.client.methods.HttpDelete class: %s", e.getMessage());
108103
}

src/main/java/io/fabric8/maven/docker/assembly/DockerFileBuilder.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
import java.io.File;
44
import java.io.IOException;
5-
import java.util.*;
5+
import java.util.ArrayList;
6+
import java.util.LinkedHashMap;
7+
import java.util.List;
8+
import java.util.Map;
69
import java.util.regex.Matcher;
710
import java.util.regex.Pattern;
811

9-
import com.google.common.base.Joiner;
1012
import io.fabric8.maven.docker.config.Arguments;
1113
import io.fabric8.maven.docker.config.HealthCheckConfiguration;
1214

@@ -21,8 +23,6 @@
2123
*/
2224
public class DockerFileBuilder {
2325

24-
private static final Joiner JOIN_ON_COMMA = Joiner.on("\",\"");
25-
2626
private static final Pattern ENV_VAR_PATTERN = Pattern.compile("^\\$(\\{[a-zA-Z0-9_]+\\}|[a-zA-Z0-9_]+).*");
2727

2828
// Base image to use as from
@@ -177,13 +177,13 @@ private static void buildArguments(StringBuilder b, DockerFileKeyword key, boole
177177
if (arguments.getShell() != null) {
178178
arg = arguments.getShell();
179179
} else {
180-
arg = "[\"" + JOIN_ON_COMMA.join(arguments.getExec()) + "\"]";
180+
arg = "[\"" + String.join("\",\"", arguments.getExec()) + "\"]";
181181
}
182182
key.addTo(b, newline, arg);
183183
}
184184

185185
private static void buildArgumentsAsJsonFormat(StringBuilder b, DockerFileKeyword key, boolean newline, Arguments arguments) {
186-
String arg = "[\"" + JOIN_ON_COMMA.join(arguments.asStrings()) + "\"]";
186+
String arg = "[\"" + String.join("\",\"", arguments.asStrings()) + "\"]";
187187
key.addTo(b, newline, arg);
188188
}
189189

src/main/java/io/fabric8/maven/docker/util/AuthConfigFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class AuthConfigFactory {
6868
"docker.io", "index.docker.io", "registry.hub.docker.com"
6969
};
7070

71-
private SettingsDecrypter settingsDecrypter;
71+
private final SettingsDecrypter settingsDecrypter;
7272

7373
/**
7474
* Constructor which should be used during startup phase of a plugin

src/main/java/io/fabric8/maven/docker/util/CredentialHelperClient.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,9 @@ public JsonObject getCredentialNode(String registryToLookup) throws IOException
118118
throw ex;
119119
}
120120
}
121-
String joinedReply = String.join("\n", reply);
122-
JsonObject credentials = JsonFactory.newJsonObject(joinedReply);
121+
JsonObject credentials = JsonFactory.newJsonObject(String.join("\n", reply));
123122
if (!credentials.has(SECRET_KEY) || !credentials.has(USERNAME_KEY)) {
124-
return null; // If keys are missing, return null
123+
return null;
125124
}
126125
return credentials;
127126
}

src/main/java/io/fabric8/maven/docker/util/ImageNameFormatter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public String doTransform(String tag, Date now) {
180180

181181
public String transform(MavenProject project, String tag, Date now) {
182182
// In case the Maven property is also a placeholder, replace it as well
183-
if(isEmpty(tag) || tag.equals("%" + letter)) {
183+
if ((tag == null || tag.trim().isEmpty()) || tag.equals("%" + letter)) {
184184
tag = project.getVersion();
185185
}
186186
return doTransform(tag, now);

0 commit comments

Comments
 (0)