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

Remove requirement of JvmPlugin from UniversalPlugin #1116

Closed
steinybot opened this issue Apr 4, 2018 · 10 comments
Closed

Remove requirement of JvmPlugin from UniversalPlugin #1116

steinybot opened this issue Apr 4, 2018 · 10 comments
Labels
universal Zip, tar.gz, tgz and bash issues

Comments

@steinybot
Copy link

Expected behaviour

I should be able to use the UniversalPlugin on a non-JVM project.

build.sbt

enablePlugins(UniversalPlugin)
disablePlugins(JvmPlugin)

Actual behaviour

→ sbt
[info] Loading settings from idea.sbt ...
[info] Loading global plugins from /Users/jason/.sbt/1.0/plugins
[info] Loading settings from plugins.sbt ...
[info] Loading project definition from /source/sbt-native-packager-jvmplugin/project
[error] sbt.AutoPluginException: Error determining plugins for project 'sbt-native-packager-jvmplugin' in /source/sbt-native-packager-jvmplugin:
[error] Failed to sort List(sbt.plugins.CorePlugin, com.typesafe.sbt.packager.universal.UniversalPlugin, sbt.plugins.Giter8TemplatePlugin, sbt.plugins.IvyPlugin, com.typesafe.sbt.SbtNativePackager) topologically
[error] 	at sbt.AutoPluginException.withPrefix(Plugins.scala:138)
[error] 	at sbt.internal.Load$.translateAutoPluginException(Load.scala:974)
[error] 	at sbt.internal.Load$.finalizeProject$1(Load.scala:863)
[error] 	at sbt.internal.Load$.$anonfun$loadTransitive$15(Load.scala:958)
[error] 	at sbt.internal.Load$.timed(Load.scala:1343)
[error] 	at sbt.internal.Load$.loadTransitive(Load.scala:958)
[error] 	at sbt.internal.Load$.loadProjects$1(Load.scala:714)
[error] 	at sbt.internal.Load$.$anonfun$loadUnit$10(Load.scala:717)
[error] 	at sbt.internal.Load$.timed(Load.scala:1343)
[error] 	at sbt.internal.Load$.$anonfun$loadUnit$1(Load.scala:717)
[error] 	at sbt.internal.Load$.timed(Load.scala:1343)
[error] 	at sbt.internal.Load$.loadUnit(Load.scala:677)
[error] 	at sbt.internal.Load$.$anonfun$builtinLoader$4(Load.scala:477)
[error] 	at sbt.internal.BuildLoader$.$anonfun$componentLoader$5(BuildLoader.scala:158)
[error] 	at sbt.internal.BuildLoader.apply(BuildLoader.scala:223)
[error] 	at sbt.internal.Load$.loadURI$1(Load.scala:539)
[error] 	at sbt.internal.Load$.loadAll(Load.scala:555)
[error] 	at sbt.internal.Load$.loadURI(Load.scala:485)
[error] 	at sbt.internal.Load$.load(Load.scala:464)
[error] 	at sbt.internal.Load$.$anonfun$apply$1(Load.scala:253)
[error] 	at sbt.internal.Load$.timed(Load.scala:1343)
[error] 	at sbt.internal.Load$.apply(Load.scala:253)
[error] 	at sbt.internal.Load$.defaultLoad(Load.scala:69)
[error] 	at sbt.BuiltinCommands$.liftedTree1$1(Main.scala:707)
[error] 	at sbt.BuiltinCommands$.doLoadProject(Main.scala:707)
[error] 	at sbt.BuiltinCommands$.$anonfun$loadProjectImpl$2(Main.scala:680)
[error] 	at sbt.Command$.$anonfun$applyEffect$4(Command.scala:134)
[error] 	at sbt.Command$.$anonfun$applyEffect$2(Command.scala:130)
[error] 	at sbt.MainLoop$.processCommand(MainLoop.scala:154)
[error] 	at sbt.MainLoop$.$anonfun$next$2(MainLoop.scala:137)
[error] 	at sbt.State$$anon$1.runCmd$1(State.scala:242)
[error] 	at sbt.State$$anon$1.process(State.scala:248)
[error] 	at sbt.MainLoop$.$anonfun$next$1(MainLoop.scala:137)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error] 	at sbt.MainLoop$.next(MainLoop.scala:137)
[error] 	at sbt.MainLoop$.run(MainLoop.scala:130)
[error] 	at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:108)
[error] 	at sbt.io.Using.apply(Using.scala:22)
[error] 	at sbt.MainLoop$.runWithNewLog(MainLoop.scala:102)
[error] 	at sbt.MainLoop$.runAndClearLast(MainLoop.scala:58)
[error] 	at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:43)
[error] 	at sbt.MainLoop$.runLogged(MainLoop.scala:35)
[error] 	at sbt.StandardMain$.runManaged(Main.scala:113)
[error] 	at sbt.xMain.run(Main.scala:76)
[error] 	at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
[error] 	at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
[error] 	at xsbt.boot.Launch$.run(Launch.scala:109)
[error] 	at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
[error] 	at xsbt.boot.Launch$.launch(Launch.scala:117)
[error] 	at xsbt.boot.Launch$.apply(Launch.scala:18)
[error] 	at xsbt.boot.Boot$.runImpl(Boot.scala:41)
[error] 	at xsbt.boot.Boot$.main(Boot.scala:17)
[error] 	at xsbt.boot.Boot.main(Boot.scala)
[error] sbt.AutoPluginException: Error determining plugins for project 'sbt-native-packager-jvmplugin' in /source/sbt-native-packager-jvmplugin:
[error] Failed to sort List(sbt.plugins.CorePlugin, com.typesafe.sbt.packager.universal.UniversalPlugin, sbt.plugins.Giter8TemplatePlugin, sbt.plugins.IvyPlugin, com.typesafe.sbt.SbtNativePackager) topologically
[error] Use 'last' for the full log.

Information

  • What sbt-native-packager are you using: 1.3.3
  • What sbt version: 1.1.2
  • What is your build system (e.g. Ubuntu, MacOS, Windows, Debian ): MacOS
  • What package are you building (e.g. docker, rpm, ...): Zip
  • What version has your build tool (find out with e.g. rpm --version): ?
  • What is your target system (e.g. Ubuntu 16.04, CentOS 7): Universal
@muuki88 muuki88 added the universal Zip, tar.gz, tgz and bash issues label Apr 5, 2018
@muuki88
Copy link
Contributor

muuki88 commented Apr 5, 2018

Thanks for your detailed report. I wasn't able to find any references to the JvmPlugin in sbt-native-packagers code base 🤔

I thought we it referenced somewhere, because we make use of javaOptions, but I wasn't able to find any in the the SbtNativePackager Plugin nor in the UniversalPlugin .

It looks like you created a minimal project reproducing this. Can you post the build.sbt or the repo here?

@dwickern
Copy link
Collaborator

dwickern commented Apr 5, 2018

AutoPlugin requires JvmPlugin by default:
https://github.com/sbt/sbt/blob/34d311f9cef2732d0427060fd7c8e704a46cba52/main/src/main/scala/sbt/Plugins.scala#L86

@muuki88
Copy link
Contributor

muuki88 commented Apr 5, 2018

Thanks for the research. I missed that this was added.

@muuki88 muuki88 closed this as completed Apr 5, 2018
@steinybot
Copy link
Author

steinybot commented Apr 5, 2018

So no chance of getting UniversalPlugin to override requires to be Plugins.empty or CorePlugin?

@muuki88
Copy link
Contributor

muuki88 commented Apr 6, 2018

I curious what your use-case is or the trouble that the JvmPlugin causes.
Maybe we can fix it another way.

The reason I'm very carefully about this, is that we rely on settings initialized
by the JvmPlugin (e.g. javaOptions). When auto-plugins where introduced
the JvmPlugin wasn't required by default and a lot of people (including me)
had issues with uninitialized settings due to a wrong auto-plugin hierarchy.

This is why I'm actually quite happy the sbt-team added the JvmPlugin by
default, because sbt main use case is jvm projects after all.

Having said that, with scala native and scala js there are two other major, non-jvm
platforms that sbt may build. In all my pet/talk projects I haven't encountered any
issues so far with the JvmPlugin.

@steinybot
Copy link
Author

Yeah I think you're right, I don't remember a specific problem, it's just a little odd.

In my particular case I had a Python project which would end up getting additional plugins added to it unnecessarily. I was trying to disable the JvmPlugin to stop them being added, alternatively I could have just disabled those plugins, although mildly inconvenient.

There may have been something else but I was probably using the wrong task at the time. It may just be a case of needing to redefine some of the settings to make it less JVM like, which would be required even if the JvmPlugin was disabled.

The only other thing is that IntelliJ IDEA ends up adding the Java SDK to the module. I haven't found a particular problem with this either though. It might be an interesting experiment to think how the IntelliJ-scala plugin could handle this better and only then might it be necessary to disable the JvmPlugin.

Without a specific problem to solve it seems perfectly fine to leave this as is.

@muuki88
Copy link
Contributor

muuki88 commented Apr 6, 2018

Wow 😎 : ! That's pretty interesting what you are saying. So you build a python project with sbt and sbt-native-packager ? If possible, can you tell a little bit more about the use case you are having? It's always super interesting to get some infos from non-standard builds.

Without a specific problem to solve it seems perfectly fine to leave this as is.

Yep 🙈

@steinybot
Copy link
Author

We have a bunch of Lagom projects which use sbt-docker. The docker packaging uses the Universal config. This part is pretty standard.

Each Lagom project also has other deployment related files such as for Terraform. This uses another Deploy config which extends Universal. I also have a derived deploy project which will automatically add all the Deploy / mappings from each Lagom project. This then creates one tarball with all the deployment artifacts.

One of those projects also has an AWS lambda function written in Python that needs to get zipped up and put within the Terraform module of the deploy tarball. There are some custom tasks which go and fetch all the Python dependencies but essentially just add everything that the lambda needs to Universal / mappings. The dependent Lagom project then just adds Universal / packageBin from the lambda project to its own Deploy / mappings at the correct path.

@muuki88
Copy link
Contributor

muuki88 commented Apr 9, 2018

Thanks a lot for sharing 😍
It's super helpful to see how native-packager is used ☺️

@steinybot
Copy link
Author

Thanks for maintaining native-packager! It is a super useful plugin. The fact that it can be used in this way is testament to how awesome it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
universal Zip, tar.gz, tgz and bash issues
Projects
None yet
Development

No branches or pull requests

3 participants