Skip to content

Commit

Permalink
Fix test failed because of the immutable map
Browse files Browse the repository at this point in the history
  • Loading branch information
devkanro committed Dec 31, 2018
1 parent 126fc5d commit 86a4ffd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ class DockerExtension {
}

public void tag(String taskName, String tag) {
if (namedTags.putIfAbsent(taskName, tag) == null) {
if (namedTags.putIfAbsent(taskName, tag) != null) {
StyledTextOutput o = project.services.get(StyledTextOutputFactory.class).create(DockerExtension)
o.withStyle(StyledTextOutput.Style.Error).println("WARNING: Task name '${taskName}' of docker tag '${tag}' is existed.")
o.withStyle(StyledTextOutput.Style.Error).println("WARNING: Task name '${taskName}' is existed.")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.Delete
import org.gradle.api.tasks.Exec
import org.gradle.api.tasks.bundling.Zip
import org.gradle.internal.logging.text.StyledTextOutput
import org.gradle.internal.logging.text.StyledTextOutputFactory

import javax.inject.Inject
import java.util.regex.Pattern
Expand Down Expand Up @@ -135,20 +137,21 @@ class PalantirDockerPlugin implements Plugin<Project> {
tagName: tagName,
tagTask: { -> tagName }
]]
}.asImmutable()
}

if (!ext.tags.isEmpty()) {
ext.tags.each { unresolvedTagName ->
String taskName = generateTagTaskName(unresolvedTagName)

if (tags.containsKey(taskName)) {
throw new GradleException("Task name '${taskName}' of docker tag '${unresolvedTagName}' is existed.")
StyledTextOutput o = project.services.get(StyledTextOutputFactory.class).create(DockerExtension)
o.withStyle(StyledTextOutput.Style.Error).println("WARNING: Task name '${taskName}' is existed.")
}else{
tags[taskName] = [
tagName: unresolvedTagName,
tagTask: { -> computeName(ext.name, unresolvedTagName) }
]
}

tags[taskName] = [
tagName: unresolvedTagName,
tagTask: { -> computeName(ext.name, unresolvedTagName) }
]
}
}

Expand Down

0 comments on commit 86a4ffd

Please sign in to comment.