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

sbt 1.0.4 puts the -sources.jar and -docs.jar in the compile config in ivy.xml #3784

Closed
sjrd opened this issue Nov 30, 2017 · 4 comments
Closed
Assignees
Milestone

Comments

@sjrd
Copy link

sjrd commented Nov 30, 2017

steps

Using the following build.sbt:

inThisBuild(Def.settings(
  organization := "com.example",
  scalaVersion := "2.11.12"
))

lazy val compplugin = project.
  settings(
  )
$ echo sbt.version=0.13.16 > project/build.properties
$ sbt compplugin/clean compplugin/publishLocal
[...]
$ cp ~/.ivy2/local/com.example/compplugin_2.11/0.1-SNAPSHOT/ivys/ivy.xml ivy-from-sbt013.xml
$ echo sbt.version=1.0.4 > project/build.properties
$ sbt compplugin/clean compplugin/publishLocal
[...]
$ cp ~/.ivy2/local/com.example/compplugin_2.11/0.1-SNAPSHOT/ivys/ivy.xml ivy-from-sbt104.xml
$ diff -u ivy-from-sbt013.xml ivy-from-sbt104.xml > ivy.xml.diff

Results in this gist: https://gist.github.com/sjrd/39b487f3f1f3abb4a5910f583e6d0e9a

problem

The ivy.xml published by sbt 1.0.4 declares the src and doc artifacts in the compile conf, instead of sources/docs as it should.

Concretely, this means that when one depends on such a project, the -sources.jar and -docs.jar are downloaded and added to the compile-time and run-time classpaths!

In the particular case of a scalac compiler plugin, since the -sources.jar also contains the scalac-plugin.xml identifying the jar as a compiler plugin, depending on it with % "plugin" causes two -Xplugin: options to be passed to scalac: one for foo.jar and one for foo-sources.jar. Depending on which one comes first (which I have experienced is non-deterministic), scalac will succeed or fail to load the plugin.

expectation

I expect the same behavior as sbt 0.13, which is also documented as an example of the Ivy documentation for <artifact>: the src artifact should have conf="sources" and the doc artifact should have conf="docs".

notes

In addition to the really serious issue above, sbt 1.0.4 also exposes private configurations used by sbt in the ivy.xml, such as compile-internal.

sbt version: 1.0.4

@sjrd
Copy link
Author

sjrd commented Nov 30, 2017

This is a blocker for us to migrate the build of Scala.js to sbt 1. Currently our CI fails because of this issue, as can be seen in the PR scala-js/scala-js#3200.

@eed3si9n
Copy link
Member

source and docs going into compile is an intentional behavior introduced in 2013 by @dansanduleac as #1016 into 0.14 branch, but was never released, and then became sbt/librarymanagement#25.

If this is causing interference with compiler plugin detection, that might be the buggy code.

@sjrd
Copy link
Author

sjrd commented Dec 13, 2017

IIRC, the compiler plugin issue happened when

  • I published the compiler plugin with sbt 1.0.4, under ^^0.13.16
  • then used the compiler plugin from a project using sbt 0.13.16

I think there was no issue when using the compiler plugin from a project using sbt 1.x itself.

So if the changes in sbt/librarymanagement#25 were indeed correct, it seems that something needs to be fixed in 0.13.x for it to be able to correctly resolve artifacts published by sbt 1.x.

eed3si9n added a commit to eed3si9n/sbt that referenced this issue Jan 6, 2018
Fixes sbt#3784

For Ivy repos, sbt 1.x publishes source and scaladoc JARs under `compile` configuration with types `src` and `doc` respectively. The current 0.13 implementation of `autoPlugins(...)` is not filtering them out correctly, and ends up including a source JAR as a compiler plugin.
@eed3si9n eed3si9n self-assigned this Jan 6, 2018
eed3si9n added a commit to eed3si9n/sbt that referenced this issue Jan 6, 2018
Fixes sbt#3784

For Ivy repos, sbt 1.x publishes source and scaladoc JARs under `compile` configuration with types `src` and `doc` respectively. The current 0.13 implementation of `autoPlugins(...)` is not filtering them out correctly, and ends up including a source JAR as a compiler plugin.
@dwijnand dwijnand modified the milestones: 1.1.1, 0.13.17 Jan 9, 2018
@dwijnand
Copy link
Member

dwijnand commented Jan 9, 2018

Fixed in (upcoming - currently RC1) 0.13.17, with #3855 merged.

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