Skip to content

Commit

Permalink
Merge pull request #16 from palantir/feature/apply-both-plugins
Browse files Browse the repository at this point in the history
Create "docker" configuration only once when both plugins are applied
  • Loading branch information
uschi2000 committed Dec 10, 2015
2 parents 530f587 + 667ffee commit bfe7828
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ class DockerComposePlugin implements Plugin<Project> {
void apply(Project project) {
DockerComposeExtension ext =
project.extensions.create('dockerCompose', DockerComposeExtension, project)
project.configurations.create("docker")
if (!project.configurations.findByName('docker')) {
project.configurations.create('docker')
}

Copy generateDockerCompose = project.tasks.create('generateDockerCompose', Copy, {
description = 'Populates docker-compose.yml.template file with image versions specified by "docker" ' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ class PalantirDockerPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
DockerExtension ext = project.extensions.create('docker', DockerExtension, project)
project.configurations.create("docker")
if (!project.configurations.findByName('docker')) {
project.configurations.create('docker')
}

Delete clean = project.tasks.create('dockerClean', Delete, {
description = "Cleans Docker build directory."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,24 @@ class PalantirDockerPluginTests extends AbstractPluginTest {
["foogroup", "barmodule", "0.1.2", temporaryFolder.root.name, "2.3.4"].each { dockerPom.contains(it) }
!dockerPom.contains("guava")
}

def 'Can apply both "docker" and "docker-compose" plugins'() {
given:
temporaryFolder.newFile('Dockerfile') << "Foo"
buildFile << '''
plugins {
id 'com.palantir.docker'
id 'com.palantir.docker-compose'
}
docker {
name 'foo'
}
'''.stripIndent()

when:
BuildResult buildResult = with('tasks').build()
then:
buildResult.task(':tasks').outcome == TaskOutcome.SUCCESS
}
}

0 comments on commit bfe7828

Please sign in to comment.