Commit Graph

10242 Commits

Author SHA1 Message Date
Eugene Yokota 44451b9a24 sbt 1.3.0-RC2 2019-06-10 17:36:01 +02:00
eugene yokota e67d86f641
Merge pull request #4792 from eatkins/dont-print-stacktrace
Remove err.printStackTrace in MainLoop
2019-06-10 01:13:13 +02:00
Ethan Atkins 54d79e664d Remove err.printStackTrace in MainLoop
I added this for debugging and did not mean to leave it in. It causes
massive walls of text to be printed sometimes when compilation fails.
2019-06-09 15:59:08 -07:00
eugene yokota d05e7e0613
Merge pull request #4790 from eed3si9n/wip/bumpzinc
Zinc 1.3.0-M7
2019-06-10 00:54:12 +02:00
Eugene Yokota f697e3a907 Zinc 1.3.0-M7 2019-06-09 23:04:32 +02:00
eugene yokota 94d5eca166
Merge pull request #4786 from eatkins/close-classloaders
Close classloaders
2019-06-09 02:52:22 +02:00
Ethan Atkins a38d2669e1 Add system property for closing classloaders
I realized that some builds may crash if we automatically close the
classloaders. While I do think that is a good thing in general that we
are closing the loaders by default, we shuold have an option for
supressing this behavior.

I made all of the custom classloaders that we define for test and run
check this property before calling the super.close method.
2019-06-08 17:07:39 -07:00
Ethan Atkins a6bc7b1c76 Fix typo 2019-06-08 17:06:34 -07:00
eugene yokota 10ca452bd8
Merge pull request #4785 from eatkins/welcome-banner
Welcome banner
2019-06-09 00:57:54 +02:00
Ethan Atkins 5e0b9a0c2f Add welcome banner to sbt shell
We want to notify users about the new features available in sbt 1.3.0 to
increase visibility. Turbo mode especially can benefit many builds, but
we have opted to leave it off by default for now.

The banner will be displayed the first time sbt enters the shell command
on each sbt run. The banner can be disabled globally with the sbt.banner
system property. It can be displayed on a per sbt version by running the
skipWelcomeBanner command. That command touches a file in the ~/.sbt/1.0
directory to make it persistent across all projects.
2019-06-08 14:09:39 -07:00
Ethan Atkins cd0461e301 Improve reload warnings
I decided creations/deletions/updates were a bit too technical rather
than descriptive. It also wasn't really correct to say Meta build
sources because the meta build is the build for the build. Instead, I
dropped Meta from the sentence. I also made the instructions when
changed sources are detected more active. I left them capitalized since
they are instructions rather than warnings.

Apply these changes by running `reload`.
Automatically reload the build when source changes are detected by setting `Global / onChangedBuildSource := ReloadOnSourceChanges`.
Disable this warning by setting `Global / onChangedBuildSource := IgnoreSourceChanges`.

Also indentation was wrong for the printed files when multiple files had
changed because the mkString middle argument was "  \n" rather than "\n  ".
2019-06-08 13:55:19 -07:00
eugene yokota 47cd001eea
Merge pull request #4783 from eed3si9n/wip/layeringstrategy
turbo mode
2019-06-08 22:32:48 +02:00
Eugene Yokota 6878fb6cdb turbo mode
This creates a performance mode that enables experimental or advanced features that might require some debugging by the build user when it doesn't work.

Initially we are putting the layered ClassLoader (`ClassLoaderLayeringStrategy.AllLibraryJars`) behind this flag.
2019-06-08 21:37:50 +02:00
Eugene Yokota 006722f81c centralize system properties 2019-06-08 19:53:59 +02:00
eugene yokota 299bdcd372
Merge pull request #4784 from eatkins/fix-scala-instance-test
Wait for akka termination in test
2019-06-08 19:52:30 +02:00
Ethan Atkins ef5a595472 Wait for akka termination in test
We now correctly close the test classloader which can cause this
scripted test to fail if the classloader is closed before the actor
system finishes terminating.
2019-06-08 10:16:47 -07:00
eugene yokota fd0f078c73
Merge pull request #4780 from eatkins/java-reflection-v2
Java reflection v2
2019-06-07 07:53:14 +02:00
eugene yokota efa26d6eb5
Merge pull request #4782 from eatkins/reuse-sbt-classpath
Re-use metabuild scala instance layer
2019-06-07 07:16:12 +02:00
Ethan Atkins f1698d2bf2 Re-use metabuild scala instance layer
At some point I noticed that projects with no scala sources in the build
loaded significantly faster than projects that had even a single scala
file -- no matter how simple that file was. This didn't really make
sense to me because *.sbt files _do_ have to be compiled. I finally
realized that classloading was a likely bottle neck because *.sbt
files are compiled on the sbt classpath while *.scala files are compiled
with a different classloader generated by the classloader cache. It then
occurred to me that we could pre-fill the classloader cache with the
scala layer of the sbt metabuild classloader.

I found that compared to 1.3.0-M5, a project with a simple scala file in
the project directory loaded about 2 seconds faster after this change.
Even if there are no scala sources in the build.sbt, there is a similar
performance improvement for running "sbt compile", which I found exited
2-3 seconds faster after this change.
2019-06-06 21:02:24 -07:00
Ethan Atkins 286e52793c Overhaul dependency layer for java reflection
My first attempt, cc8c66c66d, at making
java reflection work with a layered classloader with a dependency jar
layer was a failure. It would generally work ok the first time the user
ran test, but was likely to fail on a second run.

There were a number of problems with the strategy:
1) It relied on the thread's context class loader to determine where to
   attempt the reverse lookup.
2) It is not possible to ever reload classes loaded by a classloader.
   Consider the classloading hierarchy a <- b, where
   the arrow implies that a is the parent of b. I incorrectly thought
   that a's loadClass method would be called every time a class loaded
   by a made a call to Class.forName(name: String). This turns out to
   not be the case. As a result, the second time the dependency layer
   was used, where now the hierarchy is a <- c, that same Class.forName
   call could return a Class from b which causes a nasty crash.

It isn't possible to work around the limitation in 2 so the only option
that allows both caching and java reflection across layers to work is to
cache the dependency layer, but invalidate when cross layer reflection
occurs. This turns out to be straightforward to implement. The
performance looks very similar to the ScalaLibrary strategy when java
reflection is used, which makes sense because the scala library and
scala reflect layers are still reused when the dependency layer is
invalidated.

I also stopped passing around the resource map to all of the layers.
Resource loading is hierarchical and the resource layer comes above the
dependency layer in the stack so there was no need for the bottom layers
to also be RawResource loaders.
2019-06-06 19:17:59 -07:00
Ethan Atkins 76f3bb271e Close test classloaders correctly
While testing some classloader changes, I realized that we didn't always
close the test classloaders because they didn't necessarily extend
URLClassLoader, but instead implemented AutoCloseable.

Bonus: don't set the context classloader. It turns out that the test
framework does that anyway inside of trl.run so it was pointless to do
in Defaults.scala.
2019-06-06 19:17:59 -07:00
Ethan Atkins cbf1793f51 Add final modifier to some ClassLoaders 2019-06-06 19:17:59 -07:00
Ethan Atkins 66d3d8d504 Use named loader for ScalaLibrary
I'd already made a ScalaReflect loader and it makes sense to have a
ScalaLibraryClassLoader as well.
2019-06-06 19:17:59 -07:00
eugene yokota af0cfc9740
Merge pull request #4777 from asakaev/fix-typo
Fix typo
2019-06-06 17:15:33 +02:00
Akhtyam Sakaev 3ea9f8a71b
fix typo 2019-06-06 08:05:16 +03:00
eugene yokota 602e65d711
Merge pull request #4775 from eatkins/revert-bad-commit
Revert "revert doc"
2019-06-05 21:15:18 +00:00
Ethan Atkins 32c2afaf2d Revert "revert doc"
It was only a matter of time before this erroneously got merged in.

This reverts commit 05aab1035a.
2019-06-04 16:45:16 -07:00
eugene yokota a2598d18d3
Merge pull request #4771 from dwijnand/issue-templates
Auto-label bug reports & delete old issue template
2019-06-04 12:42:15 -04:00
Dale Wijnand d48080adf1
Auto-label bug reports & delete old issue template 2019-06-04 08:01:18 +01:00
eugene yokota 1461f2c3d6
Merge pull request #4770 from eed3si9n/wip/bumpio
IO 1.3.0-M11
2019-06-04 01:29:51 -04:00
Eugene Yokota dabc4f8c8e IO 1.3.0-M11 2019-06-04 00:14:42 -04:00
eugene yokota 331271b052
Merge pull request #4761 from dwijnand/document-BuildStructure
Document helper functions in BuildStructure
2019-06-03 23:51:26 -04:00
eugene yokota e31fd3f082
Merge pull request #4765 from eatkins/watch-docs
Watch docs
2019-06-03 22:36:46 -04:00
eugene yokota ff94258116
Merge pull request #4769 from eatkins/java-reflection
Java reflection
2019-06-03 22:35:53 -04:00
Ethan Atkins 1ab666daf4 Change signature of pre watch methods
It makes the method parameters more clear if we pass in the ProjectRef
rather than the project name. We also don't lose information.
2019-06-03 17:41:08 -07:00
Ethan Atkins 05aab1035a revert doc 2019-06-03 17:35:01 -07:00
Ethan Atkins 70899e5cad Switch private[sbt] status of Reload objects
The Reload exception that I added in the sbt package really wasn't
intended to be public. It's only meant to be used by
checkMetaBuildSources, which the users shouldn't override. I put it in
the top package though because I wanted it to be next to FullReload. I
also am not sure why the Reload object in Watch was private[sbt], but
while writing documentation, I realized that users couldn't access it.
2019-06-03 17:35:01 -07:00
Ethan Atkins 7948408368 Simplify watch callbacks
While writing documentation for the watch subsystem, I realized that
it's awkward to configure watch to clear the screen before task
evaluation. To make this easier, I added a setting watchBeforeCommand
which is an arbitrary function that will run before the watch process
evaluates the command(s).

I also added helper functions for adding clear screen functionality.

I also realized that we weren't using the watchOnEnter or
watchOnExit callbacks anywhere. I had added these to support setting up
some state before watch starts and cleaning it up before it exits for
plugin authors. It makes sense to remove that functionality for 1.3.0
and only if a need presents itself re-add it in a later version of sbt.

I also made a few apis private[sbt] that I'm not sure about. Writing
documentation made me realize that some of these are redundant and/or
not ready for general consumption.
2019-06-03 17:35:01 -07:00
Ethan Atkins 3c81226ba9 Add sbt.nio.Watch to default imports
I realized writing documentation that it is a pain to not have Watch
available in build.sbt with an import.
2019-06-03 17:35:01 -07:00
Ethan Atkins 4f66b81e03 Fix parameters in watchTriggeredMessage 2019-06-03 17:35:01 -07:00
Ethan Atkins 2905373ff7 Use logger instead of directly printing to System.err 2019-06-03 17:35:01 -07:00
Ethan Atkins 67cbd6c50e Move watch default settings
I had previously set some of the watch settings at the global level and
some at the project level. While writing documentation for the new watch
subsystem, I realized that the defaults should be set globally so that
they can be overridden at the ThisBuild level.

I also moved watchTriggers to sbt.nio.Keys. It was an oversight that it
wasn't moved there in a5cefd45be.
2019-06-03 17:35:01 -07:00
Ethan Atkins 4193cc323d Remove leading semicolon from multi command help 2019-06-03 17:35:01 -07:00
Ethan Atkins 1b8f0ed20f Don't use filtered classpath
The classpath filter for test and run was added in #661 to ensure that
the classloaders were correctly isolated. That is no longer necessary
with the new layering strategies that are more precise about which jars
are exposed at each level. Using the filtered classloader was causing
the reflection used by spark to fail when using java 11.
2019-06-03 17:26:14 -07:00
Ethan Atkins ce6484f4b4 Set java source and target levels
Since sbt must run on jdk8, we should be setting the javac source and
target levels.
2019-06-03 17:26:14 -07:00
Ethan Atkins 014190a048 Add spark scripted test
This test ensures that a simple spark app will work with all of the
classloader layering strategies. Spark is an important part of the scala
ecosystem and heavily taxes classloading.

The test just checks that the app runs. I verified manually that the
first time that run is evaluated takes about 8 seconds regardless of the
layering strategy. It drops to 6 seconds with the ScalaLibrary strategy.
It drops to 1 seconds with AllLibraryJars.
2019-06-03 17:26:14 -07:00
Ethan Atkins 233307b696 Fix classpath filter in run
We were incorrectly building the dependency layer in the run task using
the raw jars from dependencyClasspath rather than the actual classpath
jars (which may be different if bgCopyClasspath is true -- which it is
by default). This was preventing spark from working with AllLibraryJars
because it would load its classes and resources from the coursier cache
but the classpath filter would reject the resources because they came
from the coursier cache instead of the classpath.
2019-06-03 17:26:14 -07:00
Ethan Atkins 625470cdd5 Make LayeredClassLoaders parallel capable
The docs for ClassLoader,
https://docs.oracle.com/javase/8/docs/api/java/lang/ClassLoader.html
say that all non-hierarchical custom classloaders should be registered
as parallel capable. The docs also suggest that custom classloaders
should try to only override findClass so I reworked LayerdClassLoader to
only override findClass. I also added locking to the class loading to
make it safe for concurrent loading.

All of the custom classloaders besides LayeredClassLoader either
subclass URLClassLoader or LayeredClassLoader but don't override
loadClass. Because those two classloaders are parallel capable, the
subclasses should be as well. It isn't possible to make classloaders
that are implemented in scala parallel capable because scala 2 doesn't
support jvm static blocks (dotty does support this with an annotation).
To work around this, I re-worked some of the classloaders so that they
are either directly implemented in java or I subclassed a scala
implementation class in java.
2019-06-03 17:26:14 -07:00
Ethan Atkins cc8c66c66d Support java reflection with layered classloaders
Jave reflection did not work with layered classloaders if a dependency
attempted to load a class that was below the dependency layer in the
layered classloader hierarchy. The underlying problem was (in general) a
call to Class.forName somewhere. If the classloader parameter is not
specified, then Class.forName locates the ClassLoader for the caller
using reflection. It ultimately delegates to that ClassLoader's
loadClass method. With the previous LayeredClassLoader class, there was
no way for that classloader to access a URL that was below it in the
class loading hierarchy. I reworked LayeredClassLoader so that if it
fails to load the class, it will check the Thread's context classloader
and see if there are other LayeredClassLoader instances below it. If so,
it will then check if any of those classloaders would be able to load
the class by using findResource. If the descendant loader can load the
class, then we manually load it with findClass.
2019-06-03 14:21:59 -07:00
Ethan Atkins a3cde88db4 Fix runtime scala-reflect layer
For best caching performance, we want to use the scala-reflect.jar that
is found in the scala instance. Also, in the runtime configuration,
caching didn't work correctly because we filtered the scala reflect
library from the dependency jars. We really only wanted to filter out
the library jars.

It also was problematic to use a LayeredClassLoader for the scala
reflect layer because in a subsequent commit I add the capability for a
layered classloader to load classes from its descendant loaders. This
caused problems when the scala-reflect layer was a LayeredClassLoader.
Instead, I add the ScalaReflectClassLoader class for better reporting.
2019-06-03 14:21:59 -07:00