Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker:publish should skip non-Docker projects #974

Closed
fommil opened this issue May 12, 2017 · 8 comments
Closed

docker:publish should skip non-Docker projects #974

fommil opened this issue May 12, 2017 · 8 comments

Comments

@fommil
Copy link

fommil commented May 12, 2017

cheating a bit, this short test project for this standardisation plugin (the vast majority of which can be ignored)

https://github.com/cakesolutions/sbt-cake/blob/master/src/sbt-test/sbt-cake/simple/build.sbt

defines 3 projects, only two of which enable the DockerPlugin. If I type sbt docker:publishLocal it bails when it hits the logging project. But since the plugin hasn't been enabled I would have expected it to just skip this project, much as it:test only runs for projects with integration tests.

@fommil fommil changed the title docker:publishLocal should skip packages docker:publishLocal should skip projects May 12, 2017
@fommil
Copy link
Author

fommil commented May 12, 2017

ok, somebody added a dockerRepository key to every project... which probably confused the plugin. They have been scolded appropriately.

@fommil fommil closed this as completed May 12, 2017
@muuki88
Copy link
Contributor

muuki88 commented May 14, 2017

Hm. Setting a key enables the plugin? That wouldn't be very intuitive IMHO

@fommil fommil reopened this May 15, 2017
@fommil
Copy link
Author

fommil commented May 15, 2017

aha! The problem seems to be with docker:publish not docker:publishLocal. It seems to aggregate everything even if the DockerPlugin is not enabled. I don't know why.

@fommil fommil changed the title docker:publishLocal should skip projects docker:publish should skip non-Docker projects May 15, 2017
@muuki88
Copy link
Contributor

muuki88 commented May 15, 2017

So when you start your example project and list the plugins in sbt with sbt plugins the DockerPlugin is not enabled, but still docker:publish calls the docker:publish task on the logging project?

@muuki88
Copy link
Contributor

muuki88 commented May 15, 2017

Ahhh.. I have a guess. The inConfig contruct not only sets tasks in the actual configuration scope you supply, but even more.

I guess these lines are responsible that the publish task also executes some docker stuff. Still I wonder why publishLocal works?

What does inspect logging/docker:publish return?

So, the quick fix is to override the publish task in the logging project.

fernandohackbart pushed a commit to fernandohackbart/bikeride-lagom that referenced this issue Jan 27, 2018
fernandohackbart pushed a commit to fernandohackbart/bikeride-lagom that referenced this issue Jan 27, 2018
@fommil fommil closed this as completed Aug 27, 2018
@Qthunder
Copy link

Why was this closed? Still seems to be an issue

@muuki88
Copy link
Contributor

muuki88 commented Sep 30, 2019

I closed this as there wasn't any activity for a long time. Feel free to open a pull request if this is an issue for you 😃 If you need any guidance aside from the comments above, don't hesitate to ask.

@muuki88
Copy link
Contributor

muuki88 commented Jan 4, 2021

From @nigredo-tori

The issue here is that Docker/publish falls through to Compile/publish even if DockerPlugin is not enabled.

DockerPlugin is not enabled. This has to do with how Docker configuration is defined.

As a quick workaround, you can add a plugin like this:

object DockerForwardPlugin extends AutoPlugin {
  override requires = DockerPlugin
  override trigger = allRequirements

  object autoImport {
    val forwardedDockerPublish = taskKey[Unit]("Docker/publish for projects with DockerPlugin")
  }
  import autoImport._

  val projectSettings = Seq(
    forwardedDockerPublish := (Docker / publish).value
  )
}

, and use forwardedDockerPublish instead. forwardedDockerPublish will only be defined for projects with DockerPlugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants