Skip to content

deal with classpath issues during bootstrapping #5

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

Closed
adriaanm opened this issue Mar 8, 2014 · 10 comments
Closed

deal with classpath issues during bootstrapping #5

adriaanm opened this issue Mar 8, 2014 · 10 comments

Comments

@adriaanm
Copy link
Contributor

adriaanm commented Mar 8, 2014

core dependencies are dropped by ivy because of faux circular dependencies

to avoid problem with circular dependency when bootstrapping the modules

compilers in (Compile, doc) := {
  val instance = scalaInstance.value
  val cp = (packageBin in Compile).value +: instance.allJars
  println(s"Classpath for scalaInstance =\n\t * ${cp mkString "\n\t * "}")
  val launcher = appConfiguration.value.provider.scalaProvider.launcher
  val newInstance = ScalaInstance(instance.libraryJar, instance.compilerJar, launcher, cp:_*)
  Compiler.compilers(newInstance, classpathOptions.value, javaHome.value)(appConfiguration.value, streams.value.log)
}
@adriaanm
Copy link
Contributor Author

adriaanm commented Mar 8, 2014

or:

val scalaInstanceFromUpdate = TaskKey[ScalaInstance]("scala-instance-from-update", "Defines the Scala instance to use for compilation, running, and testing.")

scalaInstanceFromUpdate := Defaults.scalaInstanceFromUpdate.value

scalaInstance := {
 val s = state.value
 val extracted = Project.extract(s)
 val newState = extracted.append(List(version := "1.0.0-BLA", libraryDependencies += "junit" % "junit" % "4.10" % "scala-tool"), s)
 val newState2 = extracted.runTask(Keys.update, newState)._1
 val inst = extracted.runTask(scalaInstanceFromUpdate, newState2)._2
 println(inst.allJars.toList)
 inst
}

@gkossakowski
Copy link
Contributor

Won't the first method result in picking up Scala version used by sbt itself?

@gkossakowski
Copy link
Contributor

core dependencies are dropped by ivy because of faux circular dependencies

What does it mean? For a while I thought that the problem is that a module (let's say scala-xml) defines a project "org.scala-lang.modules" %% "scala-xml" % xxx but then this project depends on scala-tools configuration (to resolve scala compiler) and scala-compiler depends on scala-xml so we get a circular dependency. I thought that the solution would be to resolve scala-tools configuration in isolation from the project so Ivy wouldn't see the dependency and wouldn't complain. This is safe because scala-tools consits of JARs used at runtime of scala compiler/scaladoc/repl. They should never be part of the classpath used for compiling.

@adriaanm
Copy link
Contributor Author

adriaanm commented Mar 8, 2014

This is unrelated to the testing issues we were talking about. This is about bootstrapping a release, and this is confirmed to resolve the problem.

The current workaround is: https://github.com/scala/jenkins-scripts/blob/master/job/scala-release-2.11.x#L124 -- set a dummy version for scala-xml, build docs, then set real version and build the release. The dummy version is needed because ivy drops jars involved in a circular dependency from the classpath and thus scaladoc fails because it can't find any scala-xml classes. The cycle occurs because scaladoc depends on the very same version of scala-xml that it's documenting.

@SethTisue
Copy link
Member

@szeiger is this no longer an issue in the 2.12 build?

@szeiger
Copy link

szeiger commented Dec 1, 2016

It's the first time I look at this ticket and I don't understand what it's about. The link above is not stable. I tried to look in the history but it wasn't obvious to me what it's supposed to point at. Since the dependencies on scala-xml haven't changed in 2.12, I have no reason to believe that it would behave any differently than in 2.11.

@adriaanm
Copy link
Contributor Author

adriaanm commented Dec 1, 2016

It would affect 2.12 in the same way as 2.11. My recollection is that we had to put temporary version number hacks in place in the bootstrap script when documenting the modules because we would be depending on scala-xml (for running scaladoc) while documenting scala-xml (same version). This cycle caused ivy to drop this artifact from the class path, which would cause scaladoc to fail. The same hack that resolved this in 2.11 is also in place for 2.12 AFAIK

@ashawley
Copy link
Member

ashawley commented Dec 1, 2016

Is this the same issue that causes scala/scala-xml#112 (among others)? Or a different one?

@adriaanm
Copy link
Contributor Author

adriaanm commented Dec 1, 2016 via email

@SethTisue
Copy link
Member

I am closing this, because I think the solution is to finally just cut the remaining thin dependency of the scaladoc tool on scala-xml, and forbid any such circular dependencies between scala and it modules from ever arising again. circular dependencies are what Pandora's box was full of

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

No branches or pull requests

5 participants