Commit Graph

2765 Commits

Author SHA1 Message Date
Ethan Atkins b6cdd60cf8 Simplify layering strategies
The ShareRuntimeDependenciesLayerWithTestDependencies strategy doesn't
really work with resources, so it makes sense to get rid of it. Without
the share layer, there is no point in having separate
RuntimeDependencies and TestDependencies layers so I consolidated them
to Dependencies.

If we really care about binary/source compatibility for the 1.3.0-RCx
series, I can restore the traits and objects and set them private[sbt].
I think it was kind of a bug that they existed at all given the issue
with resources so it makes sense to just remove them.
2019-05-28 09:53:36 -07:00
Ethan Atkins 468334f142 Don't use anonymous URLClassLoaders
This makes debugging a bit easier in the eclipse memory analyzer tool
since we get a more specific classloader type than URLClassLoader and by
giving the class a meaningful name, we can tell from where it
originated.
2019-05-28 09:53:35 -07:00
Ethan Atkins af9f665649 Use new ClassLoaderCache for layered classloaders
This commit removes the ClassLoaderCache that I'd added for the purpose
of caching layered classloaders. Instead, we will use the state's global
ClassLoaderCache. This is better both because it centralizes the
classloader caching and because the new ClassLoaderCache will evict
unused classloaders when the jvm is under memory pressure.

I also add a new layer for the resources that goes between the scala
library layer and the dependency layer. This should help in cases where
users depend on libraries that require access to resources, e.g.
logback.xml.
2019-05-28 09:53:35 -07:00
Ethan Atkins a128ddf4a6 Route all ScalaInstance creations through the cache
It was possible to make new classloaders for the scala library and other
jars with each new scala instance. To avoid this, I audited all of the
places within sbt where we make a ScalaInstance and ensure that we
instantiate them in such a way that the classloaders are retrieved
through the state's ClassLoaderCache.

After this change, I found from a heap dump that it was possible to run
test in a project that uses scala 2.12.8 and have only ONE classloader
for the scala library present in the heap dump. With older versions,
there were would be up to 3 or 4 in most heap dumps.
2019-05-28 09:53:35 -07:00
Ethan Atkins 03bf539ce9 Add new ClassLoaderCache implementation
This commit adds a new ClassLoaderCache that builds on the
ClassLoaderCache that is present in zinc (and can be used to build an
instance of the zinc ClassLoaderCache to preserve compatibility). It
differs from the zinc classloader cache that it does not use direct
SoftReferences to classloaders. Instead, we create a wrapper loader
that can't load any classes and just delegates to its parent. This
allows us to add a thread that reaps the soft reference to the wrapper
loader. Crucially, we add a custom SoftReference class that has a strong
reference to the underlying classloader. This allows us to call close on
the strong reference.

The one issue with this approach is that we can't
rescue the jvm from crashing with an OOM: metaspace because the jvm
doesn't give us a chance to close and dereference the underlying
classloaders before it crashes. It WILL collect classloaders under
normal memory pressure, just not metaspace pressure. To fix this, I
check if the MaxMetaspaceSize is set via an MxBean and, if it is, we
fill the cache with regular soft references. We are going to change the
bash script to not set -XX:MaxMetaspaceSize by default so most builds
should probably end up correctly closing the classloaders after this
change. But we should break existing builds that set MaxMetaspaceSize
but don't crash.

As part of this commit, I audited all of the places where we were
instantiating ClassLoaderCache instances and instead pass in the
state's ClassLoaderCache instance. This reduces the total number of
classloaders created.
2019-05-28 09:53:35 -07:00
Ethan Atkins 20f6d22439 Fix memory leak
Using a lazy val causes the log manager to hold onto a reference to the
state. These would accumulate with each task evaluation. I found that
that in the beanpuree project, that if I ran compile 10 times in a row,
the heap usage was 40mb lower after this change.
2019-05-28 09:53:35 -07:00
Ethan Atkins f8d729cd3b Don't set fileOutputs at the compile config level
This was problematic because it had no dependency on the compile task
which meant that any other task in the config would pick up those
fileOutputs which did not make sense. I noticed this because
(resources / outputFileStamps).value would include class files.
2019-05-28 09:53:35 -07:00
Ethan Atkins df628d4f87 Improve legacy launcher
To minimize classloading and consistency between sbt instances launched
with the latest launcher compared to old launchers, I overhauled code
that replaces the app configuration and meta build classloader at
startup. The goals of this change for legacy launchers were:

1) Do not ever load the scala-library.jar from the app provider class loader.
2) Close the class loaders that are below the topLoader in the class
   loading hierarcy

For the new launcher, we simply want to avoid modifying the loader at
all.

I added the SbtParserInit class so that it was more straightforward to
preload the global instance using reflection. We now use reflection to
instantiate an SbtParserInit instance for both the legacy and new
launcher cases to simplify the logic.

After this change, the legacy loader still uses somewhat more metaspace
than the new loader, but the difference seems to be O(10MB), which
should only impact projects that were close their MaxMetaspaceSize to
begin with.

I verified using javap that none of the code in this class uses the
scala standard library which should help metaspace since we don't load
much of the scala standard library until we enter xMainImpl.run.
2019-05-28 09:53:35 -07:00
Ethan Atkins 22d5fbad13 Move external hooks definition
I verified manually that ExternalHooks were still applied by default but
that I could set the incOptions in the Test and Compile configs so that
they weren't used.

Fixes #4624
2019-05-26 19:15:55 -07:00
Eugene Yokota 5936bd1ff2 Revert Defaults.collectFiles
Fixes #4681
Ref #4649
2019-05-25 14:10:14 -04:00
Eugene Yokota 0ff97e4561 scalaCompilerBridgeDependencyResolution
Fixes #4712

This adds a specialized DependencyResolution instance called `scalaCompilerBridgeDependencyResolution` to download the compiler bridge. It has its own list of resolvers set by `scalaCompilerBridgeResolvers`. For backward compatibility, it will append `externalResolvers.value` as well.
2019-05-24 01:02:44 -04:00
Guillaume Martres 186693368d Make coursier-related tasks public
This follows the discussion in
https://github.com/coursier/coursier/issues/1181.
2019-05-21 19:10:38 +02:00
eugene yokota ecce47e5b7
Merge pull request #4703 from eed3si9n/wip/scalatest
Fixes layer 4 missing scala-reflect
2019-05-20 14:26:42 -04:00
Eugene Yokota 9d3b626567 Fix ScalaTest issue with ScalaLibrary classloader
Ref #4689
Ref #4671
2019-05-17 14:24:55 -04:00
Ethan Atkins 5a9f5a69d5 Fix warnings
These lines added new warnings that slipped through the cracks.
2019-05-15 17:27:07 -07:00
eugene yokota 15b4befa9c
Merge pull request #4679 from eatkins/rt-jar
Don't ever invalidate rt.jar
2019-05-14 22:13:45 -04:00
Ethan Atkins a820bb5623 Sort the supershell tasks by task name
This should make the output less jumpy.
2019-05-14 17:27:17 -07:00
Ethan Atkins 564aa7262b Fix TaskProgress
Supershell was not reliably working and I tracked it down to
TaskProgress not actually publishing updates during task execution. This
seemed to happen because the background task was only run once when the
task started up. Once that task exited, no further task reports would be
published. The fix is to start a new thread every time we enter
EvaluateTask. I verified manually that it did not seem to leak threads
because EvaluateTask always calls shutdown, which calls
afterAllCompleted, which stops the progress thread.

I also decreased the default report period to 100ms. I can't imagine
that this will have a big effect on performance. It can be tuned with
the sbt.supershell.sleep parameter.
2019-05-14 17:27:16 -07:00
Ethan Atkins 0d9be6dd4a Don't ever invalidate rt.jar
There are issues when using jdk > 8 where the rt.jar file can be
invalidated by ExternalHooks. This causes spurious rebuilds. I think
it's fair to assume that rt.jar never changes. If a dependency is named
rt.jar, then invalidation may not work correctly but I think that this
is the more important case to handle.

I verified that before this change, it was impossible to run
akka-actor/compile twice in a row using adopt jdk 11 and, after this
change, re-compilation worked as expected.
2019-05-14 16:53:09 -07:00
Ethan Atkins e5b54a59ea Manage shutdown hooks
I discovered that some registered shutdown hooks would crash due to
67df72ab01 because they would try to load
classes from the closed classloader. To fix this, I add a internal
shutdown hooks mechanism that can be managed by sbt. Any unevaluated
shutdown hooks will be run when the sbt main method exits. This means
that they will be run when the user calls reboot. I think that is
reasonable.
2019-05-13 17:38:56 -07:00
eugene yokota 7e5b9c521e
Merge pull request #4675 from eatkins/startup
Startup
2019-05-13 20:10:05 -04:00
eugene yokota 84bee1e440
Merge pull request #4671 from eed3si9n/wip/scalalibrary
change ClassLoaderLayeringStrategy.ScalaInstance to ScalaLibrary
2019-05-13 17:49:47 -04:00
Ethan Atkins 54412d8c59 Improve ScalaMetaBuildClassLoader construction
I realized that all of the data structures that I needed to isolate the
classpath are contained in the AppProvider interface so there was no
need to use structural reflection on the top class loader.
2019-05-13 14:40:22 -07:00
Ethan Atkins 418e7e09fd Shave O(500ms) off of sbt startup
It turns out that it can take roughly one second to instantiate a
scala.nsc.tools.Global instance for the first time. When sbt is starting
up, it also takes nearly 2 seconds to initialize logging. We can speed
up the boot time by doing these two things concurrently. On my machine,
I saw on average a 500ms decrease in startup time after this change.
2019-05-13 14:39:39 -07:00
Eugene Yokota 5c85c04e0d don't include si.allJars into the test classpath
allJars contains unwanted Scala modules.
Having this in prevents the flat classloader from working correctly.

Ref #4609
2019-05-12 23:51:17 -04:00
Eugene Yokota b00c675a19 change ClassLoaderLayeringStrategy.ScalaInstance to ScalaLibrary
Fixes #4609

ScalaInstance contains unwanted Scala modules such as scala-xml and scala-parser-combinators.
2019-05-12 23:36:12 -04:00
Eugene Yokota d8c9eb90c6 exclude inter-project resolvers when resolving the compiler bridge
Fixes #4669
2019-05-12 23:03:07 -04:00
Ethan Atkins b96be5343b Support char buffered stdin on windows in continuous
I finally realized that the trick is that for non cygwin windows, the
available method on the jline wrapped input stream always returns zero.
Unlike on posix, however, the read method is interruptible which means
that we can just spin up a background thread that polls from the input
stream and writes it into a buffer.

I verified that it was no longer necessary to hit <enter> after 'r' to
rerun the continuous command on my windows vm after this change.
2019-05-11 22:01:49 -07:00
Ethan Atkins 8f54ecd536 Check meta build sources before task evaluation
This commit finally fixes #241 by adding support for sbt to either
print a warning or automatically reload the project if the metabuild
sources have changed. To facilitate this, I introduce a new key,
metaBuildSourceOption which has three options:
1) IgnoreSourceChanges
2) WarnOnSourceChanges
3) ReloadOnSourceChanges

When the former is set, sbt will not check if the meta build sources
have changed. Otherwise, sbt will use the buildStructure / fileInputs to
get the ChangedFiles for the metabuild. If there are any changes, it
will either warn or reload the build depending on the value of
metaBuildSourceOption.

The mechanism for diffing the files is that I add a step to EvaluateTask
where, if the project has been loaded and
metaBuildSourceOption != IgnoreSourceChanges, we evaluate the needReload
task. If we need a reload, we return an error that indicates that a
Reload is necessary. When that error is detected, the MainLoop will
prepend "reload" to the pending commands for the state. Otherwise we
just print a warning and continue.

I benchmarked the overhead of this and it wasn't too bad. I generally
saw it taking 5-20ms to perform the check. Since this is only done once
per task evaluation run, I don't think it's a big deal. When
IgnoreSourceChanges is set, there is O(10us) overhead. If performance
does become a problem, we could add a global watch service and skip the
needReload evaluation if no files have been modified.

I removed the watchTrackMetaBuild key and made it so that the continuous
builds only track the meta build when
metaBuildSourceOption == ReloadOnSourceChanges
2019-05-11 22:01:49 -07:00
Ethan Atkins 4007810adb Add watchPersistFileStamps key
The persistentFileStampCache does seem to work pretty well but in case
users encounter issues, I add a boolean flag that allows the user to
turn this behavior off and always re-stamp every source file in every
task evaluation run.
2019-05-11 22:01:48 -07:00
Ethan Atkins ec09e73437 Improve cache invalidation strategy
Previously the persistent attribute map was only reset when the file
event monitor detected a change. This made it possible for the cache to
be inconsistent with the state of the file system*. To fix this, I add an
observer on the file tree repository used by the continuous build that
invalidates the cache entry for any path for which it detects a change.
Invalidating the cache does not stamp the file. That only happens either
when a task asks for the stamp for that file or when the file event
monitor reports an event and we must check if the file was updated or
not.

After this change, touching a source file will not trigger a build
unless the contents of the file actually changes.

I added a test that touches one source file in a project and updates the
content of the other. If the source file that is only ever touched ever
triggers a build, then the test fails.

* This could lead to under-compilation because ExternalHooks would not
detect that the file had been updated.
2019-05-11 22:01:48 -07:00
Ethan Atkins 3d965799f3 Fix trigger bug
I got the if condition wrong which was setting the fileInputs to have a
LastModified stamp.
2019-05-11 21:34:02 -07:00
Ethan Atkins 8a456aef8a Always inject input tasks
I had tried to be cute and only inject certain tasks if they're actually
used, but that made it so that dynamic tasks may not have be able to use
them.
2019-05-11 21:34:02 -07:00
Ethan Atkins 40dc3ff7b3 Move json formatters
Organizationally this was sloppy with the FileStamp implementation
classes split by a bunch of json formatters.
2019-05-11 21:34:02 -07:00
Ethan Atkins f60d4060dd Fix toString for Update 2019-05-11 21:34:02 -07:00
Ethan Atkins b6ad077a72 Update io
The new io verion removes the PathFinder <-> Glob implicit translations.
It also has a number of small bug fixes related to directory listing via
FileTreeView.
2019-05-11 21:34:02 -07:00
Ethan Atkins 2ab8fed8fd Deprecation cleanup
The main project emits a number of deprecation warnings. I've isolated
the deprecation warnings related to Watch to the DeprecatedContinuous
file. I fixed the deprecation warnings where it was straightforward to
do so. After this change, there are three non-watch related changes
emitted:

1) Defaults.scala:3760 uses the deprecated InputTask.apply. This seems
   fixable but I'm not in a hurry
2) oldLoadFailed and oldLastGrep are used by Main. I think this could
   just be fixed by removing the deprecation warnings and setting them
   private[sbt] since they will still be available in the shell.
2019-05-11 21:34:02 -07:00
Ethan Atkins b15b638632 Remove unused private[sbt] key
This slipped through by mistake.
2019-05-11 21:34:02 -07:00
Ethan Atkins f9eb631b13 Filter scala-library more safely
I previously tried to fix https://github.com/sbt/sbt/issues/4608 in
fc715cab44 by finding the instance of
xsbt.boot.BootFilteredLoader in the classloader heirarchy. This was a
risky approach since it made a lot of assumptions about the classloaders
used to invoke xMain.run. Since the point is to filter out the scala
standard library jar, I reworked things to just find all the parents of
the scala provider loader and then walk the graph from the root
classloader until it finds the classloader that contains the scala
library. If no such classloader exists, it ends up returning the parent
of the scala provider library.

I also renamed the libraryLoader parameter to scalaProviderLoader since
that is what is actually passedin. It is actually the libraryLoader that
we want to exclude.
2019-05-11 19:45:25 -07:00
eugene yokota cf932c8a13
Merge pull request #4666 from eed3si9n/wip/coursierlog
silence coursier log when supershell is off
2019-05-11 19:39:21 -04:00
Eugene Yokota b18f3e8710 Reduce the test noise by making id more realistic
Fixes #3893

This fixes the flaky ParserSpec by making the id generation more realistic ASCII identifiers.
2019-05-11 03:55:34 -04:00
Eugene Yokota 7433f1f4ed make Coursier cache directory configurable 2019-05-11 01:11:07 -04:00
Eugene Yokota 9137e21028 silence coursier log when supershell is off 2019-05-11 00:56:40 -04:00
Eugene Yokota 1ba195a4f5 Refactor out keepPreloaded
Ref https://github.com/sbt/sbt/issues/4661
2019-05-11 00:13:22 -04:00
Eugene Yokota bcbd29f496 exclude preloaded local repos for now
Ref https://github.com/sbt/sbt/issues/4661
local-preloaded-ivy contains dangling ivy.xml without JAR files.
We might include local-preloaded again once we have a preloaded in Maven layout.
2019-05-09 23:34:37 -04:00
Eugene Yokota 4b9533b124 ignore bad SDKMAN directories
Fixes #4655
2019-05-09 01:59:03 -04:00
eugene yokota f5edeec2fd
Merge pull request #4647 from eed3si9n/wip/progress
Remove State out of progressReports
2019-05-03 17:51:51 -04:00
Eugene Yokota e8a22bf805 Remove State out of progressReports 2019-05-03 16:44:42 -04:00
Dale Wijnand f5495bdd67
Fix projects help usage text 2019-05-03 08:58:56 +01:00
eugene yokota 8fa3bcf90d
Merge pull request #4644 from eatkins/close-classloaders
Properly close a number of classloaders
2019-05-02 22:12:54 -04:00
eugene yokota cfa64e12d1
Merge pull request #4645 from eatkins/unnecessary-sleep
Unnecessary sleep
2019-05-02 22:04:39 -04:00
Ethan Atkins 7f719d7233 Remove unnecessary sleep
I'm not sure what the previous purpose of this was, but syncTo is
blocking so this just seems to add 100ms to the run task startup time.
2019-05-02 14:43:00 -07:00
Ethan Atkins 67df72ab01 Properly close a number of classloaders
I discovered there were a number of places where closing a ClassLoader
didn't work correctly because I was assuming it was a URLClassLoader
when it was actually a ClasspathFilter. I also incorrectly imported the
wrong kind of URLClassLoader in Run.scala. Finally, I close the
SbtMetaBuildClassLoader when xMain exits now.
2019-05-02 14:38:33 -07:00
Ethan Atkins 507346f3f6 Simplify file management settings
I decided that there were too many settings related to the file
management that did similar things and had similar names but did
slightly different things. To improve this, I introduce the ChangedFiles
class to sbt.nio.file and switch to having just two task for file input
and output retrieval: all(Input|Output)Files and
changed(Input|Output)Files. If, for example, changedInputFiles returns
None that means that either the task has not yet been run or there were
no changes. If there have been any changes, then it will return
Some(changes) and the user can extract the relevant changes that they
are interested in.

The code may be slightly more verbose in a few places, but I think it's
worth it for the conceptual clarity.
2019-05-02 14:36:08 -07:00
Ethan Atkins 3319423369 Add full support for managing file task io
This commit unifies my previous work for automatically watching the
input files for a task with support for automatically tracking and
cleaning up the output files of a task. The big idea is that users may
want to define tasks that depend on the file outputs of other tasks and
we may not want to run the dependent tasks if the output files of the
parent tasks are unmodified.

For example, suppose we wanted to make a plugin for managing typescript
files. There may be, say, two tasks with the following inputs and
outputs:

compileTypescript = taskKey[Unit]("shells out to compile typescript files")
  fileInputs -- sourceDirectory / ** / "*.ts"
  fileOutputs -- target / "generated-js" / ** / "*.js"

minifyGeneratedJS = taskKey[Path]("minifies the js files generated by compileTypescript to a single combined js file.")
  dependsOn: compileTypeScript / fileOutputs

Given a clean build, the following should happen
> minifyGeneratedJS
// compileTypescript is run
// minifyGeneratedJS is run

> minifyGeneratedJS
// no op because nothing changed

> minifyGeneratedJS / clean
// removes the file returned by minifyGeneratedJS.previous

> minifyGeneratedJS
// re-runs minifyGeneratedJS with the previously compiled js artifacts

> compileTypescript / clean
// removes the generated js files

> minifyGeneratedJS
// compileTypescript is run because the previous clean removed the generated js files
// minifyGeneratedJS runs because the artifacts have changed

> clean
// removes the generated js files and the minified js file

> minifyGeneratedJS
// compileTypescript is run because the generated js files were
// minifyGeneratedJS is run both because it was removed and

Moreover, if compileTypescript fails, we want minifyGeneratedJS to fail
as well.

This commit makes this all possible. It adds a number of tasks to
sbt.nio.Keys that deal with the output files. When injecting settings, I
now identify all tasks that return Seq[File], File, Seq[Path] and Path
and create a hidden special task: dynamicFileOutputs: TaskKey[Seq[Path]]
This special task runs the underlying task and converts the result to
Seq[Path]. From there, we can have the tasks like changedOutputPaths
delegate to dynamicFileOutputs which, by proxy, runs the underlying
task. If any task in the input / output chain fails, the entire sequence
fails.

Unlike the fileInputs, we do not register the dynamicFileOutputs or
fileOutputs with continuous watch service so these paths will not
trigger a continuous build if they are modified. Only explicit unmanaged
input sources should should do that.

As part of this, I also added automatic generation of a custom clean task for
any task that returns Seq[File], File, Seq[Path] or Path. I also added
aggregation so that clean can be defined in a configuration or project
and it will automatically run clean for all of the tasks that have a
custom clean implementation in that task or project. The automatic clean
task will only delete files that are in the task target directory to
avoid accidentally deleting unmanaged files.
2019-05-02 14:36:08 -07:00
Ethan Atkins 7166aca0c2 Rename InputGraph to SettingsGraph 2019-05-02 14:36:08 -07:00
Ethan Atkins a5cefd45be Clean up nio apis
This commit refactors things so that the nio apis are located primarily
in the nio package. Because the nio keys are a first class sbt feature,
I had to add import sbt.nio._ and sbt.nio.Keys._ to the autoimports in
BuildUtil.scala
2019-05-02 14:36:06 -07:00
Ethan Atkins 2d1c80f916 Remove duped system in
I had some ideas for allowing the user to get a copy of system in during
a continuous build but I can't really see a good use case now so I'm
going to remove it before 1.3.0.
2019-05-02 14:33:29 -07:00
Ethan Atkins 72df8f674c Add support for managed task inputs
In my recent changes to watch, I have been moving towards a world in
which sbt manages the file inputs and outputs at the task level. The
main idea is that we want to enable a user to specify the inputs and
outputs of a task and have sbt able to track those inputs across
multiple task evaluations. Sbt should be able to automatically trigger a
build when the inputs change and it also should be able to avoid task
evaluation if non of the inputs have changed.

The former case of having sbt automatically watch the file inputs of a
task has been present since watch was refactored. In this commit, I
make it possible for the user to retrieve the lists of new, modified and
deleted files. The user can then avoid task evaluation if none of the
inputs have changed.

To implement this, I inject a number of new settings during project
load if the fileInputs setting is defined for a task. The injected
settings are:

allPathsAndAttributes -- this retrieves all of the paths described by
  the fileInputs for the task along with their attributes
fileStamps -- this retrieves all of the file stamps for the files
  returned by allPathsAndAttributes

Using these two injected tasks, I also inject a number of derived tasks,
such as allFiles, which returns all of the regular files returned by
allPathsAndAttributes and changedFiles, which returns all of the regular
files that have been modified since the last run.

Using these injected settings, the user is able to write tasks that
avoid evaluation if the inputs haven't changed.

foo / fileInputs += baseDirectory.value.toGlob / ** / "*.scala"
foo := {
  foo.previous match {
    case Some(p) if (foo / changedFiles).value.isEmpty => p
    case _ => fooImpl((foo / allFiles).value
  }
}

To make this whole mechanism work, I add a private task key:
val fileAttributeMap = taskKey[java.util.HashMap[Path, Stamp]]("...")
This keeps track of the stamps for all of the files that are managed by
sbt. The fileStamps task will first look for the stamp in the attribute
map and, only if it is not present, it will update the cache. This
allows us to ensure that a given file will only be stamped once per task
evaluation run no matter how the file inputs are specified. Moreover, in
a continuous build, I'm able to reuse the attribute map which can
significantly reduce latency because the default file stamping
implementation used by zinc is fairly expensive (it can take anywhere
between 300-1500ms to stamp 5000 8kb source files on my mac).

I also renamed some of the watch related keys to be a bit more clear.
2019-05-02 14:33:29 -07:00
Ethan Atkins ba1f690bba Make Repository private[sbt]
This trait may not even survive until 1.4.0. It should definitely not be
public. I got a little overexcited about programming with higher kinded
types when I added it.
2019-05-02 14:33:02 -07:00
Ethan Atkins 41c63c1028 Remove unneeded filters 2019-05-02 14:33:02 -07:00
Ethan Atkins 2deac62b00 Bump io
The newest version of io repackages a number of classes into the
sbt.nio.* packages. It also changes some of the semantics of glob
related apis. This commit updates all of the usages of the updated apis
within sbt but should have no functional difference.
2019-05-02 14:33:01 -07:00
Ethan Atkins 20b0ef786b Undeprecate WatchSource
Since the new watch implementation has yet to be widely deployed, we
should hold off on deprecating the old keys. They could still be
deprecated in a patch release or in 1.4.0.
2019-05-02 09:41:53 -07:00
Ethan Atkins 3a6ff8afca Use global classloader cache for scala instance
I noticed in a heap dump of sbt that there were many classloaders for
the scala instance. I then realized that we were making a new
classloader for the scala library on every test run. Even worse, the
ScalaInstanceLoader instance was never closed which lead to a metaspace
leak. I moved the scala instance classloader to the global classloader
cache. Not only will these be correctly cached, they will be closed if
evicted from the cache.
2019-04-30 12:33:43 -07:00
Eugene Yokota 788a864d83 Refactor some code 2019-04-29 10:33:08 -04:00
eugene yokota 1106422fb9
Merge pull request #4617 from dwijnand/zinc-lm-integration
In-source zinc's LM integration code
2019-04-28 22:19:43 -04:00
eugene yokota 33f4f5a49b
Merge pull request #4630 from eed3si9n/wip/cancelable
make Global / cancelable true by default
2019-04-28 18:17:41 -04:00
Eugene Yokota f5444f7715 Merge branch 'develop' into pr/4617 2019-04-28 17:22:54 -04:00
Eugene Yokota f999f6a62e always reresolve sbt artifacts when using Coursier
Ref #4589

This requires sbt server tests to resolve sbt off of local.
2019-04-27 14:31:13 -04:00
Eugene Yokota 96ad731e8c Use allExcludeDependencies 2019-04-26 18:06:10 -04:00
Eugene Yokota 8c0f13a24a manually expand ivy.home
Ref coursier/coursier#1124
2019-04-26 17:51:17 -04:00
Eugene Yokota f354a626c7 use lm-coursier-shaded
This uses lm-coursier-shaded, and follows along the changes in https://github.com/coursier/sbt-coursier/pull/58.
2019-04-26 17:33:14 -04:00
Eugene Yokota 24db77edc5 copy some tests from coursier/sbt-coursier
Copying over sbt-coursier integration tests that do not depend on Coursier-specific things, but excercises sbt integration.
2019-04-26 12:27:38 -04:00
Eugene Yokota 7658f14762 Add maven-plugin and test-jar to classpathTypes
Ref https://github.com/sbt/sbt-native-packager/issues/1053
Ref https://github.com/coursier/coursier/issues/450
2019-04-26 12:27:38 -04:00
Eugene Yokota ca53934941 fix csrCachePath 2019-04-26 12:27:38 -04:00
Eugene Yokota 944e955d06 put sbtCp ahead of resolved JARs
Ref https://github.com/sbt/sbt/pull/4443
Ref https://github.com/coursier/coursier/issues/1128

This is a workaround for Coursier not excluding sbt modules.
2019-04-26 12:27:38 -04:00
Eugene Yokota 5614cfcbb6 Move log to outer task 2019-04-26 12:27:38 -04:00
Eugene Yokota e206e797fe set up specific dependencyResolution instances 2019-04-26 12:27:38 -04:00
Eugene Yokota 6a99906386 manually expand ivy.home
Ref https://github.com/coursier/coursier/issues/1124
2019-04-26 12:25:52 -04:00
Eugene Yokota 21782a51f0 write info.apiURL to ivy.xml
Ref https://github.com/coursier/coursier/issues/1123
2019-04-26 12:25:52 -04:00
Eugene Yokota 38f94a6e31 Coursier dependency resolution integration
This adds dependency to LM implemented using Coursier.
I had to copy paste a bunch of code from sbt-coursier-shared to break the dependency to sbt.

`Global / useCoursier := false` or `-Dsbt.coursier=false` be used to opt-out of using Coursier for the dependency resolution.
2019-04-26 12:25:52 -04:00
Eugene Yokota 3be8efc36e make Global / cancelable true by default
Fixes #3252
2019-04-25 12:14:37 -04:00
Dale Wijnand e978357e47
In-source zinc's LM integration code 2019-04-25 11:57:37 +01:00
Eugene Yokota 6c7faf2b86 trim update and add updateFull
Fixes #4438

This slims down update's UpdateReport by removing evicted modules
caller information. The larger the graph, the effect would be more
pronounced. For example, I saw a graph reduce from 5.9MB to 1.1MB in JSON file.
2019-04-23 14:08:17 -04:00
eugene yokota 4074cb32d3
Merge pull request #4605 from eed3si9n/wip/bumplm
bump to lm 1.3.0-M3
2019-04-23 13:52:08 -04:00
eugene yokota 9b71ee1d6e
Merge pull request #4459 from alexarchambault/topic/update-classifiers-dependency-resolution
Have updateClassifiers use the dependencyResolution task
2019-04-21 19:18:01 -04:00
Eugene Yokota 465ff8e10a Make loggers synchronized
This is to workaround for "[success]" logs displaying after the prompt is displayed.
2019-04-21 04:03:22 -04:00
Eugene Yokota c4d6efe5af move super shell rendering to logger
Fixes #4583
Ref https://github.com/sbt/util/pull/196
2019-04-20 23:32:42 -04:00
Eugene Yokota 1e157b991a apply formatting 2019-04-20 03:23:54 -04:00
Dale Wijnand 546476981c
Resolve compilation warnings in test/Delegates 2019-04-18 09:21:08 +01:00
Ethan Atkins fc715cab44 Don't leak the sbt boot scala library into tests
It was reported in https://github.com/sbt/sbt/issues/4608 that there was
a regression that tests run against scala 2.11 would fail. This was
because the interface loader incorrectly contained the scala library. To
fix this, I needed to find the xsbt.boot.BootFilteredLoader in the
classloading hierarchy and put the sbt testing interface library in
between that loader and the scala library loader.
2019-04-07 15:08:52 -07:00
Ethan Atkins c9aec02d05 Improve toString for flat classloader
It can be helpful to see what jars are available to the underlying url
classloader as well as what the parent classloader is.
2019-04-07 15:08:52 -07:00
Eugene Yokota bf44a6f446 add header 2019-04-06 02:08:21 -04:00
Eugene Yokota 8790a7b45d bump to lm 1.3.0-M3
This also adds `CustomHttp.okhttpClient` and `CustomHttp.okhttpClientBuilder` settings to experimentally customize HTTP client.
2019-04-05 15:28:49 -04:00
Ethan Atkins 031e9463da Improve error reporting for classloading issues
We noticed that the community build was failing for some projects due to
some class loading issues. My initial approach for detecting the errors
didn't always work because the test framework might wrap the underlying
exception. To fix that, I add the causes to the list of throwables to
scan for class loading related exceptions. I also added
ClassNotFoundException to the list of types to check for. I additionally
added more context to the error message so that it is more clear to the
user what specifically went wrong. The error message is intended to
provide examples that the user can actually paste into the console.
There is also a lot of manual line wrapping that could be improved by
defining paragraphs and then splitting on the jline terminal width. That
could be a useful internal helper function to improve our log messages
in general.

The underlying issue could be addressed by allowing the user to specify
libraries that get excluded from the dependency classpath for layering
purposes. I'm not sure the best way to do that yet and adding that
feature wouldn't fix any existing builds so I think that would be better
handled in 1.4.0.
2019-04-03 11:02:49 -07:00
Ethan Atkins 73cfd7c8bd Don't leak the sbt metabuild classpath in run/test
Prior to this commit, it was difficult to prevent the sbt metabuild
classpath from leaking into the runtime and test classpaths. The biggest
issue is that the test-inferface jar was located in the metabuild
classpath. We tried to prevent leakage using the DualClassLoader, but
this was an ugly solution that did not seem to work reliably. The fix is
to modify the actual sbt metabuild classloader provided by the sbt
launcher.

To do this, I add a new classloader SbtMetaClassLoader that isolates the
test-interface jar from the rest of the classpath. I modify xMain to
create a new AppConfiguration that uses this new classloader and
use reflection to invoke the sbt main method using the new classloader.

Not only do I think that this is a much saner solution than DualLoaders,
I accidentally fixed #4575 with this change.
2019-04-02 20:53:37 -07:00
Ethan Atkins 2c19138394 Fix classpath ordering for layered classloaders
The order of the classpath was not previously preserved because I
converted the runtime and test classpaths to set. I fix that in this
commit.
2019-04-02 20:53:37 -07:00
Ethan Atkins 399dd920b0 Set bgCopyClasspath false for shared layer config
It isn't possible to share the runtime and test layers correctly with
bgCopyClasspath is used because the runtime classpath uses the
dependencies copied to the boot directory while the test classpath uses
the classes in target and .ivy2. Since this is not the default and users
have to opt in to
ClassLoaderLayeringStrategy.ShareRuntimeDependenciesLayerWithTestDependencies,
I think this is fine.
2019-04-02 20:53:37 -07:00
Ethan Atkins a4f1d23d71 Close test and run classloaders
It's good practice to call close on a URLClassLoader when we're done
with it.
2019-04-02 20:53:37 -07:00
Ethan Atkins 8ef5a67b64 Add better error message if run fails
It is possible with the new layering strategies that tests may fail if a
java package private class is accessed across classloader layers. This
will result in an IllegalAccessError that is hard to debug. With this
commit, I add an error message that will be displayed if run throws an
IllegalAccessError that suggests that the user try the
ScalaInstance layering strategy or the flat layering strategy.
2019-04-02 20:53:37 -07:00
Ethan Atkins cb7fbfc810 Use named parameters 2019-04-02 20:53:37 -07:00
Ethan Atkins 13cdbb5ea6 Don't make redundant ClassLoaderCache instance
I noticed that sometimes multiple ClassLoaderCache instances were
created in each configuraiton. I believe this was due to the use of
inConfig(...)(...) causing multiple caches to be created. Long term, I'm
not sure that taskRepository and classLoaderCache are the right
solutions so I made classLoaderCache private[sbt] as well.
2019-04-02 20:53:37 -07:00
Ethan Atkins 7f46b27143 Change default FileTree implementation
I have noticed on linux that the file cache updates aren't fast enough
for ExternalHooks. Say you have project b that depends on project a.
With a clean build, if you run b/compile, the file cache may not yet see
the changes to *.class files generated by project a. There are multiple
ways to fix this:
* don't use the file cache for binary products
* use the analysis results to invalidate the cache
* switch over to my hypothetical replacement file system

In the meantime, we should stop spamming users by default.
2019-03-31 22:15:28 -07:00
Ethan Atkins e33bb691ee Fix depth condition on GlobLister.aggregate
I wrote this check in a rush and realized that it didn't quite match the
correct glob semantics. The depth parameter is effectively the index of
the array of sorted child directories of the base. That index is
computed with getNameCount - 1, not getNameCount. It is also inclusive,
not exclusive, hence the switch from `<` to `<=`.

This change was motivated by my reviewing the initial change in the
context of the fix to https://github.com/sbt/sbt/issues/4591.
2019-03-31 09:34:06 -07:00
Ethan Atkins eb2926b004 Validate the cache by default
This commit change the default FileTree.Repository to always use a polling file
repository but one that validates the current file system results
against the cache results. On windows, we do not validate the cache
because the cache can cause io contention in scripted tests. The
cache does seem to work ok on my VM, but not on appveyor for whatever
reason. Validating the cache by default was suggested by @smarter in a
comment in https://github.com/sbt/sbt/issues/4543.
2019-03-30 16:39:10 -07:00
Ethan Atkins 247d242008 Improve watch messages
This commit reworks the watch start message so that instead of printing
something like:

[info] [watch] 1. Waiting for source changes... (press 'r' to re-run the command, 'x' to exit sbt or 'enter' to return to the shell)

it instead prints something like:

[info] 1. Monitoring source files for updates...
[info] Project: filesJVM
[info] Command: compile
[info] Options:
[info]   <enter>: return to the shell
[info]   'r': repeat the current command
[info]   'x': exit sbt

It will also print which path triggered the build.
2019-03-30 16:39:10 -07:00
Ethan Atkins c72005fd2b Support inputs in dynamic tasks
Prior to this commit, it was necessary to add breadcrumbs for every
input that is used within a dynamic task. In this commit, I rework the
watch setup so that we can track the dynamic inputs that are used. To
simplify the discussion, I'm going to ignore aggregation and
multi-commands, but they are both supported. To implement this change, I
update the GlobLister.all method to take a second implicit argument:
DynamicInputs. This is effectively a mutable Set of Globs that is
updated every time a task looks up files from a glob. The repository.get
method should already register the glob with the repository. The set of
globs are necessary because the repository may not do any file filtering
so the file event monitor needs to check the input globs to ensure that
the file event is for a file that actually requested by a task during
evaluation.

* Long term, I plan to add support for lifting tasks into a dynamic task
in a way that records _all_ of the possible dependencies for the task
through each of the dynamic code paths. We should revisit this change to
determine if its still necessary after that change.
2019-03-30 16:39:10 -07:00
Ethan Atkins 7c2607b1ae Clean up file repository management
I had needed to add proxy classes for the global FileTreeRepository so
that tasks that called the close method wouldn't actually stop the
monitoring done by the global repository. I realized that it makes a lot
more sense to just not provide direct access to the underlying file tree
repository and let the registerGlobalCaches manage its life cycle
instead.
2019-03-30 16:39:10 -07:00
Ethan Atkins 9cdeb7120e Add StateTransform class
This commit cleans up the approach for transforming the sbt state upon
completion of a task returning State. I add a new approach where a task
can return an instance of StateTransform, which is just a wrapper around
State. I then update EvaluateTask to apply this stateTransform rather
than the (optional) state transformation that may be stored in the Task
info parameter. By requiring that the user return StateTransform rather
than State directly, we ensure that no existing tasks that depend on the
state transformation function embedded in the Task info break. In sbt 2,
I could see the possibility of making this automatic (and probably
removing the state transformation function via attribute).

The problem with using the transformState attribute key is that it is
applied non-deterministically. This means that if you decorate a task
returning State, then the state transformation may or may not be
correctly applied.

I tracked this non-determinism down to the stateTransform
method in EvaluateTask. It iterates through the task result map and
chains all of the defined transformState attribute values. Because the
result is a map, this order is not specified. This chaining is arguably
a bad design because State => State does not imply commutivity. Indeed,
the problem here was that my state transformation functions were
constant functions, which are obviously non-commutative. I believe that
this logic likely written under the assumption that there would be no
more than one of these tranformations in a given result map.
2019-03-30 16:39:10 -07:00
Ethan Atkins 40d8d8876d Create Watch.scala
I decided that it makes sense to move all of the new watch code out of
the Watched companion object since the Watched trait itself is now
deprecated. I don't really like having the new code in Watched.scala
mixed with the legacy code, so I pulled it all out and moved it into the
Watch object. Since we have to put all of the logic for the Continuous
object in main in order to access the sbt.Keys object, it makes sense to
move the logic out of main-command and into command so that most of the
watch related logic is in the same subproject.
2019-03-30 16:39:10 -07:00
Ethan Atkins e868c43fcc Refactor Watched
This is a huge refactor of Watched. I produced this through multiple
rewrite iterations and it was too difficult to separate all of the
changes into small individual commits so I, unfortunately, had to make a
massive commit. In general, I have tried to document the source code
extensively both to facilitate reading this commit and to help with
future maintenance.

These changes are quite complicated because they provided a built-in
like api to a feature that is implemented like a plugin. In particular,
we have to manually do a lot of parsing as well as roll our own
task/setting evaluation because we cannot infer the watch settings at
project build time because we do not know a priori what commands the
user may watch in a given session. The dynamic setting and task
evaluation is mostly confined to the WatchSettings class in Continuous.
It feels dirty to do all of this extraction by hand, but it does seem to
work correctly with scopes.

At a high level this commit does four things:
1) migrate the watch implementation to using the InputGraph to collect
   the globs that it needs to monitor during the watch
2) simplify WatchConfig to make it easier for plugin authors to write
   their own custom watch implementations
3) allow configuration of the watch settings based on the task(s) that
   is/are being run
4) adds an InputTask implemenation of watch.

Point #1 is mostly handled by Point #3 since I had to overhaul how _all_
of the watch settings are generated. InputGraph already handles both
transitive inputs and triggers as well as legacy watchSources so not
much additional logic is needed beyond passing the correct scoped keys
into InputGraph.

Point #3 require some structural changes. The watch settings cannot in
general be defined statically because we don't know a priori what tasks
the user will try and watch. To address this, I added code that will
extract the task keys for all of the commands that we are running. I
then manually extract the relevant settings for each command. Finally, I
aggregate those settings into a single WatchConfig that can be used to
actually implement the watch. The aggregation is generally
straightforward: we run all of the callbacks for each task and choose
the next watch state based on the highest priority Action that is
returned by any of the callbacks.

Because I needed Extracted to pull out the necessary settings, I was
forced to move a lot of logic out of Watched and into a new singleton,
Continuous, that exists in the main project (Watched is in the command
project). The public footprint of Continuous is tiny. Even though I want
to make the watch feature flexible for plugin authors, the
implementation and api remain a moving target so I do not want to be
limited by future binary compatibility requirements. Anyone who wants to
live dangerously can access the private[sbt] apis via reflection or by
adding custom code to the sbt package in their plugin (a technique I've
used in CloseWatch).

Point #2 is addressed by removing the count and lastStatus from the
WatchConfig callbacks. While these parameters can be useful, they are
not necessary to implement the semantics of a watch. Moreover, a status
boolean isn't really that useful and the sbt task engine makes it very
difficult to actually extract the previous result of the tasks that were
run. After this refactor, WatchConfig has a simpler api. There are fewer
callbacks to implement and the signatures are simpler. To preserve the
_functionality_ of making the count accessible to the user specifiable
callbacks, I still provided settings like watchOnInputEvent that accept
a count parameter, but the count is actually tracked externally to
Watched.watch and incremented every time the task is run.

Moreover, there are a few parameters of the watch: the logger and
transitive globs, that cannot be provided via settings. I provide
callback settings like watchOnStart that mirror the WatchConfig
callbacks except that they return a function from Continuous.Arguments
to the needed callback. The Continuous.aggregate function will check if
the watchOnStart setting is set and if it is, will pass in the needed
arguments. Otherwise it will use the default watchOnStart implementation
which simulates the existing behavior by tracking the iteration count in
an AtomicInteger and passing the current count into the user provided
callback. In this way, we are able to provide a number of apis to the
watch process while preserving the default behavior.

To implement #4, I had to change the label of the `watch` attribute key
from "watch" to "watched". This allows `watch compile` to work at the
sbt command line even thought it maps to the watchTasks key. The actual
implementation is almost trivial. The difference between an
InputTask[Unit] and a command is very small. The tricky part is that the
actual implementation requires applying mapTask to a delegate task that
overrides the Task's info.postTransform value (which is used to
transform the state after task evaluation). The actual postTransform
function can be shared by the continuous task and continuous command.
There is just a slightly different mechanism for getting to the state
transformation function.
2019-03-30 16:38:56 -07:00
Ethan Atkins ed06e18fab Add InputGraph
This commit adds functionality to traverse the settings graph to find
all of the Inputs settings values for the transitive dependencies of the
task. We can use this to build up the list of globs that we must watch
when we are in a continuous build. Because the Inputs key is a setting,
it is actually quite fast to fetch all the values once the compiled map
is generated (O(2ms) in the scripted tests, though I did find that it
took O(20ms) to generate the compiled map).

One complicating factor is that dynamic tasks do not track any of
their dynamic dependencies. To work around this, I added the
transitiveDependencies key. If one does something like:
foo := {
  val _ = bar / transitiveDependencies
  val _ = baz / transitiveDependencies
  if (System.getProperty("some.prop", "false") == "true") Def.task(bar.value)
  else Def.task(baz.value)
}
then (foo / transitiveDependencies).value will return all of the inputs
and triggers for bar and baz as well as for foo.

To implement transitiveDependencies, I did something fairly similar to
streams where if the setting is referenced, I add a default
implementation. If the default implementation is not present, I fall
back on trying to extract the key from the commandLine. This allows the
user to run `show bar / transitiveDependencies` from the command line
even if `bar / transitiveDependencies` is not defined in the project.

It might be possible to coax transitiveDependencies into a setting, but
then it would have to be eagerly evaluated at project definition time
which might increase start up time too much.  Alternatively, we could
just define this task for every task in the build, but I'm not sure how
expensive that would be. At any rate, it should be straightforward to
make that change without breaking binary compatibility if need be. This
is something to possibly explore before the 1.3 release if there is any
spare time (unlikely).
2019-03-30 16:38:44 -07:00
Ethan Atkins e910a13d7f Add internalDependencyConfigurations setting
In order to walk the full dependency graph of a task, we need to know
the internal class path dependency configurations. Suppose that we have
projects a and b where b depends on *->compile in a. If we want to find
all of the inputs for b, then if we find that there is a dependency on
b/Compile/internalDependencyClasspath, then we must add a / Compile /
internalDependencyClasspath to the list of dependencies for the task.

I copied the setup of one of the other scripted tests that was
introduced to test the track-internal-dependencies feature to write a
basic scripted test for this new key and implementation.
2019-03-30 16:38:44 -07:00
Ethan Atkins 1df62b6933 Add fileInputs and watchTriggers task
This adds two new tasks: fileInputs and watchTriggers, that will be used by sbt
both to fetch files within a task as well as to create watch sources for
continuous builds. In a subsequent commit, I will add a task for a
command that will traverse the task dependency graph to find all of the
input task dependency scopes. The idea is to make it possible to easily
and accurately specify the watch sources for a task. For example, we'd
be able to write something like:

val foo = taskKey[Unit]("print text file contents")
foo / fileInputs := baseDirectory.value  **  "*.txt"
foo := {
  (foo / fileInputs).value.all.foreach(f =>
    println(s"$f:\n${new String(java.nio.Files.readAllBytes(f.toPath))}"))
}

If the user then runs `~foo`, then the task should trigger if the user
modifies any file with the "txt" extension in the project directory.
Today, the user would have to do something like:

val fooInputs = settingKey[Seq[Source]]("the input files for foo")
fooInputs := baseDirectory.value ** "*.txt"

val foo = taskKey[Unit]("print text file contents")
foo := {
  fooInputs.value.all.foreach(f =>
    println(s"$f:\n${new String(java.nio.Files.readAllBytes(f.toPath))}"))
}
watchSources ++= fooInputs.value

or even worse:

val foo = taskKey[Unit]("print text file contents")
foo := {
  (baseDirectory.value ** "*.txt").all.foreach(f =>
    println(s"$f:\n${new String(java.nio.Files.readAllBytes(f.toPath))}"))
}
watchSources ++= baseDirectory.value ** "*.txt"

which makes it possible for the watchSources and the task sources to get
out of sync.

For consistency, I also renamed the `outputs` key `fileOutputs`.
2019-03-30 16:38:44 -07:00
Ethan Atkins 6da876cbe7 Remove unneeded string interpolation 2019-03-30 16:38:44 -07:00
Ethan Atkins 81481a8af5 Disable supershell in CI
The supershell output is distracting in CI. I added a system property,
sbt.ci, to explicitly set whether or not sbt is running in a ci build.
It was not at all obvious to me if the BUILD_NUMBER or CI environment
variables were set on travis or appveyor.
2019-03-30 11:51:47 -07:00
eugene yokota ca5f978df4
Merge pull request #4589 from eed3si9n/wip/metabuild_fix
Exclude all sbt modules from metabuild resolution
2019-03-30 11:52:25 -04:00
Eugene Yokota 33e648473f Exclude major sbt modules from metabuild resolution
Fixes #4582

#4443 introduced a perf enhacement of exluding sbt out of the metabuild, and instead appending the list of JARs resolved by the sbt launcher to the classpath.
This strategy worked in most cases, but it seems like some plugins are explicitly depending on IO module. In those cases, old IO would come before the new IO in the classpath ordering, resulting to "Symbol X is missing from classpath" error.
This fixes the issue by excluding all modules whose organization is `org.scala-sbt`.

As an escape hatch, I am adding a new key `reresolveSbtArtifacts`, which can be used to opt out of this behavior.
2019-03-29 21:34:49 -04:00
Ethan Atkins 6b82a8d07e Don't use usingTerminal
The usingTerminal method synchronizes the JLine object which can lead to
deadlock if multiple threads call it. When we just to want to read the
attributes of the terminal, but not modify it, there doesn't seem to be
any reason to use a lock.
2019-03-28 20:37:49 -07:00
Eugene Yokota 29ebd1222c improve the implementation of expandJavaHomes 2019-03-26 23:06:49 -04:00
Eugene Yokota c0cd65af92 detection of SDKMAN managed JDKs 2019-03-26 18:37:36 -04:00
Eugene Yokota 6f19f76b40 migrate to ScalaTest FunSuite 2019-03-26 18:26:52 -04:00
eugene yokota de5c0434df
Merge pull request #4576 from eed3si9n/wip/trace
output Chrome traces on -Dsbt.traces=true
2019-03-25 17:21:59 -04:00
Eugene Yokota adfb2ece1a install official sbt based on project/build.properties 2019-03-25 02:10:48 -04:00
Eugene Yokota a713a62d12 widen scopes for classLoaderLayeringStrategy
Fixes #4574

This defines the `classLoaderLayeringStrategy` key at `Global` and `Zero / Test` level, and uses the scope delegation to pick them out from `test`.
2019-03-24 14:49:37 -04:00
Jason Zaugg 3600c97f1f WIP output Chrome trace format 2019-03-23 18:42:00 -04:00
Ethan Atkins f26afe6681 Return (Path, FileAttributes) instead of Stamped.File
I realized that Stamped.File was a bad interface that was really just an
implementation detail of external hooks. I updated the
GlobLister.{ all, unique } methods to return Seq[(Path, FileAttributes)]
rather than Stamped.File which is a much more natural api and one I
could see surviving the switch to nio based apis planned for
1.4.0/2.0.0. I also added a simple scripted test for glob listing. The
GlobLister.all method is implicitly tested all over the place since the
compile task uses it, but it's good to have an explicit test.
2019-03-22 09:32:36 -07:00
Ethan Atkins c3e0e117e6 Do not use caching repository by default
The caching repository does not work universally so set the default to
always poll. This is still faster than in sbt 1.2.x because of
performance improvements that I added for listing directories.
2019-03-22 09:32:36 -07:00
Ethan Atkins 467ece1ba1 Temporarily make FileTree.Repository public
This should not be exposed to users but will be for M1.
2019-03-22 09:32:36 -07:00
Ethan Atkins d231d7d9ec Rename FileCacheEntry to FileAttributes
I decided that FileCacheEntry was a bad name because the methods did not
necessarily have anything to do with caching. Moreover, because it is
exposed in a public interface, it shouldn't be in the internal package.
2019-03-22 09:32:36 -07:00
Ethan Atkins be94b25d68 Add Event trait to FileCacheEntry
Rather than exposing the FileEventMonitor.Event types, which are under
active development in the io repo, I am adding a new event trait to
FileCacheEntry. This trait doesn't expose any internal implementation
details.
2019-03-22 09:32:36 -07:00
Ethan Atkins 86200345e1 Don't expose TypedPath to users
I've decided I don't like the TypedPath interface so I'm not going to
expose it publicly.
2019-03-22 09:32:36 -07:00
Ethan Atkins fac6e0d9a0 Make file repository apis private[sbt]
I haven't fully settled on these interfaces yet so they shouldn't be publicly
exposed in the sbt api.
2019-03-22 09:32:36 -07:00
Ethan Atkins e3625ca8b0 Fix repository setup on windows
Windows io really doesn't handle concurrent readers and writers all that
well. Using the LegacyFileTreeRepository was problematic in windows
scripted tests because even though the repository implementation did not
use the cache in its list methods, it did persistently monitor the
directories that were registered. The monitor has to do a lot of
io on a background thread to maintain the cache. This caused io
contention that would cause IO.createDirectory to fail with an obscure
AccessDeniedException. The way to avoid this is to prevent the
background io from occurring at all.

I don't necessarily think this will impact most users running sbt
interactively with a cache, but it did cause scripted tests to fail. For
that reason I made the default in non-interactive/shell use cases on
windows to be a PollingFileRepository which never monitors the file
system except when we are in a watch. The LegacyFileTreeRepository works
fine on mac and linux which have a more forgiving file system.

To make this work, I had to add FileManagement.toMonitoringRepository.
There are now two kinds of repositories that cannot monitor on their
own: HybridPollingFileTreeRepository and PollingFileRepository. The
FileManagement.toMonitoringRepository makes a new repository that turns
on monitoring for those two repository types and disables the close
method on all other repositories so that closing the FileEventMonitor
does not actually close the global file repository.
2019-03-22 09:32:35 -07:00
Ethan Atkins b0c5e00c7c Reimplement clean
I ran into a couple of issues with the clean implementation. I changed
the logging to print to stdout instead of streams if enabled. I also
added a helper, Clean.deleteContents that recursively deletes all of the
contents of a directory except for those that match the exclude filter
parameter.

Using a normal logger was a bad idea because we are actually deleting
the target/streams directory when running clean.

The previous implementation worked by getting the full list of files to
delete, reverse sorting it and then deleting every element in the list.
While this can work well it many circumstances, if the directory is
still being written to during the recursive deletion, then we could miss
files that were added after we fetched all of the files. The new version
lazily lists the subdirectories as needed.
2019-03-22 09:32:35 -07:00
Ethan Atkins de3c09f99d Move clean task implementation to Clean.scala
The Defaults.scala file has a lot going on. I am trying to generally
follow the pattern of implementing the default task implementation in a
different file and just adding the appropriate declarations in
Defaults.scala.
2019-03-22 09:32:35 -07:00
Ethan Atkins 172c8e9a0b Support custom clean tasks
This rewroks the cleanTask so that it only removes a subset of the
files in the target directory. To do this, I add a new task, outputs,
that returns the glob representation of the possible output files for
the task. It must be a task because some outputs will depend on streams.
For each project, the default outputs are all of the files in
baseDirectory / target.

Long term, we could enhance the clean task to be automatically generated
in any scope (as an input task). We could then add the option for the
task scoped clean to delete all of the transitive outputs of the class.
That is beyond the scope of this commit, however.

I copied the scripted tests from #3678 and added an additional test to
make sure that the manage source directory was explicitly cleaned.
2019-03-22 09:32:35 -07:00
Ethan Atkins c77a26e832 Update clean task to use globs
The clean task is unreasonably slow because it does a lot of redundant
io. In this commit, I update clean to be implemented using globs. This
allows us to (optionally) route io through the file system cache. There
is a significant performance improvement to this change. Currently,
running clean on the sbt project takes O(6 seconds) on my machine. After
this change, it takes O(1 second).

To implement this, I added a new setting cleanKeepGlobs to replace
cleanKeepFiles. I don't think that cleanKeepFiles returning Seq[File] is
a big deal for performance because, by default, it just contains the
history file so there isn't much benefit to accessing a single file
through the cache. The reason I added the setting was more for
consistency and to help push people towards globs in their own task
implementations.

Part of the performance improvement comes from inverting the problem.
Before we would walk the file system tree from the base and recursively
delete leafs and nodes in a depth first traversal. Now we collect all of
the files that we are interested in deleting in advance. We then sort
the results lexically by path name and then perform the deletions in
that order. Because children will always comes first in this scheme,
this will generally allow us to delete a directory.

There is an edge case that if files are created in a subdirectory after
we've created the list to delete, but before the subdirectory is
deleted, then that subdirectory will not be deleted. In general, this
will tend to impact target/streams because writes occur to
target/streams during traversal. I don't think this really matters for
most users. If the target directory is being concurrently modified with
clean, then the user is doing something wrong.

To ensure legacy compatibility, I re-implement cleanKeepFiles to return
no files. Any plugin that was appending files to the cleanKeepFiles task
with `+=` or `++=` will continue working as before because I explicitly
add those files to the list to delete. I updated the actions/clean-keep
scripted test to use both cleanKeepFiles and cleanKeepGlobs to ensure
both tasks are correctly used.

Bonus: add debug logging of all deleted files
2019-03-22 07:53:41 -07:00
Ethan Atkins 571b179574 Add dsl for collecting globs
Right now, the sbt.internal.io.Source is something of a second class
citizen within sbt. Since sbt 0.13, there have been extension classes
defined that can convert a file to a PathFinder but no analog has been
introduced for sbt.internal.io.Source.

Given that sbt.internal.io.Source was not really intended to be part of
the public api (just look at its package), I think it makes sense to
just replace it with Glob. In this commit, I add extension
methods to Glob and Seq[Glob] that make it possible to easily
retrieve all of the files for a particular Glob within a task. The
upshot is that where previously, we'd have had to write something like:

watchSources += Source(baseDirectory.value / "src" / "main" / "proto", "*.proto", NothingFilter)

now we can write

watchGlobs += baseDirectory.value / "src" / "main" / "proto" * "*.proto"

Moreover, within a task, we can now do something like:
foo := {
  val allWatchGlobs: Seq[File] = watchGlobs.value.all
  println(allWatchSources.mkString("all watch source files:\n", "\n", ""))
}
Before we would have had to manually retrieve the files.

The implementation of the dsl uses the new GlobExtractor class which
proxies file look ups through a FileTree.Repository. This makes it so
that, by default, all file i/o using Sources will use the default
FileTree.Repository. The default is a macro that returns
`sbt.Keys.fileTreeRepository.value: @sbtUnchecked`. By doing it this
way, the default repository can only be used within a task definition
(since it delegates to `fileTreeRepository.value`). It does not,
however, prevent the user from explicitly providing a
FileTree.Repository instance which the user is free to instantiate
however they wish.

Bonus: optimize imports in Def.scala and Defaults.scala
2019-03-22 07:53:41 -07:00
Ethan Atkins d0310cc866 Rework FileTreeRepository configuration
The FileTreeViewConfig abstraction that I added was somewhat unwieldy
and confusing. The original intention was to provide users with a lot of
flexibility in configuring the global file tree repository used by sbt.
I don't think that flexibility is necessary and it was both conceptually
complicated and made the implementation complex. In this commit, I add a
new boolean flag enableGlobalCachingFileTreeRepository that toggles
which kind of FileTreeRepository to use globally.

There are actually three kinds of repositories that could be returned:
1) FileTreeRepository.default -- this caches the entire file system
   tree it hooks into the cache's event callbacks to create a file event
   monitor. It will be used if enableGlobalCachingFileTreeRepository is
   true and Global / pollingGlobs := Nil
2) FileTreeRepository.hybrid -- similar to FileTreeRepository.default
   except that it will not cache any files that are included in
   Global / pollingGlobs. It will be used if
   enableGlobalCachingFileTreeRepository is true and
   Global / pollingGlobs is non empty
3) FileTreeRepository.legacy -- does not cache any of the file system
   tree, but does maintain a persistent file monitoring process that is
   implemented with a WatchServiceBackedObservable. Because it doesn't
   poll, in general, it's ok to leave the monitoring on in the
   background. One reason to use this is that if there are any issues
   with the cache being unable to accurately mirror the underlying file
   system tree, this repository will always poll the file system
   whenever sbt requests the entries for a given glob. Moreover, the
   file system tree implementation is very similar to the implementation
   that was used in 1.2.x so this gives users a way to almost fully opt
   back in to the old behavior.
2019-03-22 07:53:41 -07:00
Ethan Atkins 792fb91737 Avoid deprecated Alternative class 2019-03-22 07:53:41 -07:00
Ethan Atkins f7f7addff7 Bump io
This new version of io breaks source and binary compatibility everywhere
that uses the register(path: Path, depth: Int) method that is defined on
a few interfaces because I changed the signature to register(glob:
Glob). I had to convert to using a glob everywhere that register was
called.

I also noticed a number of places where we were calling .asFile on a
file. This is redundant because asFile is an extension method on File
that just returns the underlying file.

Finally, I share the IOSyntax trait from io in AllSyntax. There was more
or less a TODO suggesting this change. The one hairy part is the
existence of the Alternative class. This class has unfortunately somehow
made it into the sbt package object. While I doubt many plugins are
using this, it doesn't seem worth breaking binary compatibility to get
rid of it. The issue is that while Alternative is defined private[sbt],
the alternative method in IOSyntax is public, so I can't get rid of
Alternative without breaking binary compatibility.

I'm not deprecating Alternative for now because the sbtProj still has
xfatal warnings on. I think in many, if not most, cases, the Alternative
class makes the code more confusing as is often the case with custom
operators. The confusion is mitigated if the abstraction is used only in
the file in which it's defined.
2019-03-22 07:53:41 -07:00
Ethan Atkins e536c4ac39 Remove unused local variable 2019-03-20 11:22:21 -07:00
Eugene Yokota 86abe3ed60 open up ExecuteProgress, and adds a few keys
Fixes #4461

This opens up ExecuteProgress API that's been around under private[sbt].
Since the state passing mechanism hasn't been used, I got rid of it.

The build user can configure the build using two keys Boolean `taskProgress` and `State => Seq[TaskProgress]` `progressReports`. `useSuperShell` is lightweight key on/off switch for the super shell that can be used as follows:

```scala
Global / SettingKey[Boolean]("useSuperShell") := false
```
2019-03-19 00:42:46 -04:00
Eugene Yokota cd1d2e0994 Util 1.3.0-M5 2019-03-08 19:18:53 -05:00
Eugene Yokota 3cd8cc4e86 Make sure progress thread gets shutdown 2019-02-26 05:10:18 -05:00
Ethan Atkins fcd24ba7cd Reduce command polling period
The only thing this function does is poll a queue and check a deadline.
There is no need to put such a large sleep duration in.
2019-02-14 21:13:07 -08:00
Ethan Atkins c37f2607f1 Lint CommandExchange.scala
Clears out intellij warnings.
2019-02-14 21:09:44 -08:00
Ethan Atkins faf6348a16 Run gc when idle
I often find that when I run a command it takes a long time to start up
because sbt triggers a full gc. To improve the ux, I update the command
exchange to run full gc only once while it's waiting for a command to
run and only after the user has been idle for at least one minute.

Bonus: optimize imports
2019-02-14 21:09:17 -08:00
Guillaume Martres 85f91e76ca Remove Dotty handling in scalaInstance
sbt-dotty 0.3.0 (https://github.com/lampepfl/dotty/pull/5835) sets
`managedScalaInstance := false` and does everything by itself, so this
isn't needed anymore.
2019-02-12 23:30:45 +01:00
eugene yokota fbadfabfe2
Merge pull request #4538 from eatkins/compiler-cache
Clear compiler cache in clearCaches
2019-02-04 10:27:14 -05:00
eugene yokota e73d1fb7c6
Merge pull request #4537 from eatkins/allow-watch-loops
Allow watch loops
2019-02-04 10:25:11 -05:00
Ethan Atkins e8af828c73 Add FileCacheEntry
Previously, we were leaking the internal details of incremental
compilation to users by defining FileTree(DataView|Repository)[Stamp].
To avoid this, I introduce the new class FileCacheEntry that is quite
similar to Stamp except defined using scala Options rather than java
Optionals. The implementation class just delegates to an actual Stamp
and I provided a private[sbt] ops class that adds a
method `stamp` to FileCacheEntry. This will usually just extract the
stamp from the implementation class. This allows us to use
FileCacheEntry almost interchangeably with Stamp while still avoiding
exposing users to Stamp.
2019-02-02 16:03:59 -08:00
Ethan Atkins ba0494df14 Stop Stamped from inheriting File and TypedPath
In the FileTreeDataView use case, we were previously working with
FileTreeDataView[Stamped], which actually contained a lot of redundant
information because FileTreeDataView.Entry[_] has a toTypedPath method
that could be used to read the path related fields in Stamped. Instead,
we can just return the Stamp itself in FileTreeDataView.list* methods
and convert to Stamped.File where needed (i.e. in ExternalHooks).

Also move BasicKeys.globalFileTreeView to Keys since it isn't actually
used in the main-command project.
2019-02-02 12:22:57 -08:00
Ethan Atkins 0bdc30b60b Rename StampedFile to Stamped 2019-02-02 12:22:57 -08:00
Ethan Atkins f44e2a2e74 Clear compiler cache in clearCaches
Resident compilation actually works pretty well most of the time*,
but if there ever is an issue with the cached compilation, we should be
able to easily clear the cache.

* I've only had issues when package objects are involved
2019-02-02 12:20:32 -08:00
Ethan Atkins 116d2ae815 Use ? instead of extracting state
I was unaware of the '?' method when I wrote this.
2019-02-01 18:01:56 -08:00
Ethan Atkins 2ef97768a0 Don't attempt to prevent certain watch loops
If the managedSources task writes into an unmanaged source directory,
that would cause an infinite loop. I don't think it's worth doing out of
band task execution to try and prevent this.
2019-02-01 18:01:56 -08:00
Ethan Atkins 92807869ea Fix community build
The community build was broken for some projects because I broke builds
that relied on the unscoped definition of `runner`. To preserve legacy
behavior, I restore the old unscoped behavior and append the new scoped
runners that used the layered classloaders. This makes more sense
because the layered classloaders were specifically designed for the
Runtime and Test configurations and may not make sense in other
contexts.
2019-01-30 20:54:08 -08:00
Ethan Atkins ba3ff8198d Remove unneeded parens in Definition.scala 2019-01-30 10:46:00 -08:00
Ethan Atkins 06a153278f Cleanup cache when CommandExchange shuts down
I noticed that sometimes when running scripted tests that I'd run out of
metaspace. I believe that this may be due to the caffeine cache leaking
classloaders. Regardless, it's a good idea to clear the cache whenever
we shutdown the command exchange or reload the state.
2019-01-30 10:45:22 -08:00
Ethan Atkins 0a4fbc9f5a Set classLoaderLayeringStrategy in relevant configs
Previously, the ClassLoaderLayeringStrategy was set globally. This
didn't really make sense because the Runtime and Test configs had
different strategies available (Test being a superset of Runtime).
Instead, we now set the layering strategy in the Runtime and Test
configurations directly. In doing this, we can eliminate the Default
ClassLoaderLayeringStrategy. Previously this had existed so that we
could set the layering strategy globally and have it do the right thing
in both test and runtime.

To implement this, I factored out the logic for generating the layered
classloader in the test task and shared it with the runtime task. I did
this because I realized that Test / run is a thing. Previously I had
been operating under the assumption that the runner would never include
the test dependencies. Once I realized this, it made sense to combine
the logic in both tasks.

As a bonus, I only allow the layering strategies that explicitly make
sense to be set in each configuration. If the user sets an invalid
strategy, an error will be thrown that specifies the valid strategies
for the task.

I also added ScalaInstance as an option for the runtime layer. It was an
oversight that this was left out.
2019-01-30 08:55:22 -08:00
Ethan Atkins 3a211710f9 Rename some layering related fields/classes
In code review, @eed3si9n suggested that I switch to a more verbose and
descriptive naming scheme. In addition to trying to make layers more
descriptive, I also made the various layer case objects extend the
relevant layers so it's more clear what the layer should look like.
2019-01-30 08:55:22 -08:00
Ethan Atkins 1ca6b97de2 JDK 11 fixes
In JDK 11, String.lines returns java.util.stream.Stream[String]. Switch
to linesIterator instead.
2019-01-30 08:55:22 -08:00
Ethan Atkins 1d467bd966 Fix FileRepository implementation for scripted
I was seeing spurious travis failures and I finally tracked it down to
the fact that in some cases, the project metabuild would sometimes use a
caching file tree repository instead of a polling repository. This
caused problems because the caching repository can take a few milliseconds
to detect changes in a directory. Because scripted copies the project
sources to the temporary test directory, it was possible for the project
meta build compilation to be initiated before the cache was aware of all
of the files.

The reason this happened was because scripted would create a state where
the remaining commands looked like:
List(sbtPopOnFailure, resumeFromFailure, notifyUsersAboutShell, iflast shell, ~compile, < 41684)
The ~compile command was causing the continuous flag to get set to true
which caused the default file tree repository task to return the caching
version. The reason for the continuous flag was so that when sbt is
started in a non-interactive mode where the command is to be repeated,
then we use the caching file tree repository. To support this use case,
we just need to check that the last command begins with `~`, not that
_any_ command begins with `~`.
2019-01-30 08:55:22 -08:00
Ethan Atkins 5fc5846737 Add TaskRepository to manage ClassLoaderCache
We want the user to be able to invalidate the classloader cache in the
event that it somehow gets in a bad state. The cache is, however,
defined in multiple configurations, so there are in fact many
ClassLoaderCache instances that are managed by sbt. To make this sane, I
add a global cache that is keyed by a TaskKey[_] and can return
arbitrary data back. Invalidating all of the ClassLoaderCache instances
is then as straightforward as just replacing the TaskRepository
instance.

I also went ahead and unified the management of the global file tree
repository. Instead of having to specifically clear the file tree
repository or the classloader cache, the user can now invalidate both
with the new clearCaches command.
2019-01-30 08:55:22 -08:00
Ethan Atkins a06f5435c6 Use layered ClassLoaders in run and test tasks
Using the data structures that I added in the previous commits, it is
now possible to rework the run and test task to use (configurable)
layered class loaders. The layering strategy is globally set to
LayeringStrategy.Default. The default strategy leads to what is
effectively a three layered ClassLoader for the both the test and run
tasks. The first layer contains the scala instance (and test framework
loader in the test task). The second layer contains all of the
dependencies for the configuration while the third layer contains the
project artifacts.

The layering strategy is very easily changed both at the Global or
Configuration level, e.g. adding
Test / layeringStrategy := LayeringStrategy.Flat
to the project build.sbt will make the test task not even use the scala
instance and instead a create a single layer containing the full
classpath of the test task.

I also tried to ensure that all of the ClassLoaders have good toString
overrides so that it's easy to see how the ClassLoader is constructed
with, e.g. `show testLoader`, in the sbt console.

In this commit, the ClassLoaderCache instances are settings. In the next
commit, I make them tasks so that we can easily clear out the caches
with a command.
2019-01-30 08:55:22 -08:00
Ethan Atkins f118a5e410 Add LayeringStrategy
This introduces a new trait LayeringStrategy that is used to configure
how sbt constructs the ClassLoaders used by the run and test tasks. In
addition to defining the various options, I try to give a good high
level overview of the problem that the LayeringStrategy is intended to
address in its scaladoc.
2019-01-30 08:55:22 -08:00
Ethan Atkins ef08290ecc Add ClassLoaderCache
In order to speed up the start up time of the test and run tasks, I'm
introducing a ClassLoaderCache that can be used to avoid reloading the
classes in the project dependencies (which includes the scala library).
I made the api as minimal as possible so that we can iterate on the
implementation without breaking binary compatibility. This feature will
be gated on a feature flag, so I'm not concerned with the cache class
loaders being useable in every user configuration. Over time, I hope
that the CachedClassLoaders will be a drop in replacement for the
existing one-off class loaders*.

The LayeredClassLoader was adapted from the NativeCopyLoader. The main
difference is that the NativeCopyLoader extracts named shared libraries
into the task temp directory to ensure that the ephemeral libraries are
deleted after each task run. This is a problem if we are caching the
ClassLoader so for LayeredClassLoader I track the native libraries that
are extracted by the loader and I delete them either when the loader is
explicitly closed or in a shutdown hook.

* This of course means that we both must layer the class loaders
appropriately so that the project code is in a layer above the cached
loaders and we must correctly invalidate the cache when the project, or
its dependencies are updated.
2019-01-30 08:55:22 -08:00
Ethan Atkins 5bbda9cf69 Add Repository interface
I am going to be introducing multiple caches throughout sbt and I am
going to build these features out using this simple Repository
interface. The idea is that we access data by some key through the
Repository. This allows us to use the strategy pattern to easily switch
the runtime implementation of how to get the data.
2019-01-30 08:55:22 -08:00
Ethan Atkins ec22d6c0da Add LRUCache to sbt.internal
I am going to add a classloader cache to improve the startup performance
of the run and test tasks. To prevent the classloader cache from having
unbounded size, I'm adding a simple LRUCache implementation to sbt. An
important characteristic of the implementation of the cache is that when
entries are evicted, we run a callback to cleanup the entry. This allows
us to automatically cleanup any resources created by the entry.

This is a pretty naive implementation that uses an array of entries that
it manipulates as elements are removed/accessed. In general, I expect
these caches to be quite small <= 4 elements, so the storage overhead /
performance of the simple implementation should be quite good. If
performance ever becomes an issue, we can specialzed LRUCache.apply to
use a different implementation for caches with large limits.
2019-01-30 08:55:22 -08:00
Ethan Atkins 161dfd77f2 Update TypedPath apis
I renamed getPath to toPath in io so we need to update sbt to using the
correct api.
2019-01-16 13:22:56 -08:00
Ethan Atkins 541d4047e6 Bump scala version 2.12.8
I ran a zsh one liner to generate this:
git grep "2.12.7" | cut -d ':' -f1 | sort | uniq | xargs perl -p -i -e "s/2.12.7/2.12.8/"
2019-01-08 11:11:23 -08:00
Thomas Droxler fff6b044bc Use `ListBuffer` instead of `List` in `LanguageServerReporter`
In order to have a better data structure for appending
2019-01-04 13:31:04 +01:00
Thomas Droxler a5388fed60 Preserve errors order when publishing diagnostics
The `sbt-server` was prepending a new probem and not appending.

The result was a `textDocument/publishDiagnostics` notification
containing a inverted list of problems compare to what was show in the
sbt console.
2019-01-04 13:31:04 +01:00
eugene yokota 1e7564c408
Merge pull request #4499 from dwijnand/ParseKey-rare-failure
Avoid ParseKey failing due to homonymous axes
2018-12-22 14:29:59 -05:00
Dale Wijnand 30dca6b818
Cleanup ConfigIndex 2018-12-22 17:05:51 +00:00
Dale Wijnand 3d924978c2
Add some matcher messaging to ParserSpec 2018-12-22 17:02:48 +00:00
Dale Wijnand 6988b2289a
Cleanup some formatting/wrapping 2018-12-22 17:02:47 +00:00
Dale Wijnand e533bc93e8
Avoid ParseKey failing due to homonymous axes 2018-12-22 12:51:47 +00:00
Dale Wijnand 645f484184
Switch ParseKey to propertyWithSeed 2018-12-22 12:51:47 +00:00
Dale Wijnand 1f14a2c340
Split out ParseKey properties 2018-12-22 12:51:47 +00:00
Dale Wijnand a254341b6f
Remove dead guessedConfigIdents code 2018-12-22 12:37:42 +00:00
Ethan Atkins bfffb4f489 Rename TestBuild.Keys to TestBuild.TestKeys
It drives me crazy that in intellij when I do the go to class task that
TestBuild.Keys comes up before Keys. Given how central Keys is to sbt,
it doesn't seem like a good idea to alias that particular class name.
2018-12-14 13:55:19 -08:00
Ethan Atkins de7c67ea45 Optimize imports in Defaults, Main and Keys
It was becoming a pain to work on these files in intellij because the
auto-import feature would implicitly optimize all of the imports in
these files, leading to a large diff. I'd then have to go and manually
add the import that I care about. This change does add some wildcard
imports, which I don't always love, but these files are so unwieldy
already that I think it's worth it to have the imports follow the format
preferred by intellij.
2018-12-03 13:28:10 -08:00
eugene yokota 34ef5ab500
Merge pull request #4454 from eed3si9n/wip/prompt-fix
Fix prompt for task progress
2018-11-29 10:47:30 -05:00
Eugene Yokota 9858bc29fb more tweaking on task progress
move the cursor up after the user enters command.
2018-11-29 04:40:40 -05:00
Ólafur Páll Geirsson fefb83f8fd Update semanticdb-scalac to v4.1.0
This release supports more Scala versions, works on Java 11 and
is ~8mb smaller than v4.0.0.
2018-11-28 08:56:18 +01:00
Arnout Engelen ae932f7390 Discover Oracle JDK installed in /opt 2018-11-22 12:50:13 +01:00
Alexandre Archambault 9fc9c49d0e Have updateClassifiers use the dependencyResolution task 2018-11-21 14:54:11 +01:00
Ethan Atkins c00cc37953 Do not require leading semicolon for multi command
It has long been a frustration of mine that it is necessary to prepend
multiple commands with a ';'. In this commit, I relax that restriction.
I had to reorder the command definitions so that multi comes before act.
This was because if the multi command did not have a leading semicolon,
then it would be handled by the action parser before the multi command
parser had a shot at it. Sadness ensued.
2018-11-19 10:42:51 -08:00
Eugene Yokota b00dcb1b9d Fix task progress blank line behavior
Run readyLog lazily.
2018-11-16 23:06:36 -08:00
Eugene Yokota d58b302a97 Fix prompt for task progress 2018-11-16 23:05:51 -08:00
Ethan Atkins 7b5cf84fe1 Fix '~' for dependent projects with a broken parent
In #4446, @japgolly reported that in some projects, if a parent project
was broken, then '~' would immediately exit upon startup. I tracked it
down to this managed sources filter. The idea of this filter is to avoid
getting stuck in a build loop if managedSources writes into an unmanaged
source directory. If the (managedSources in ThisScope).value line
failed, however, it would cause the watchSources, and by delegation,
watchTransitiveSources task to fail. The fix is to only create this
filter if the managedSources task succeeds.

I'm not 100% sure if we shouldn't just get rid of this filter entirely
and just document that '~' will probably loop if a build writes the
result of managedSources into an unmanaged source directory.
2018-11-11 09:35:46 -08:00
Eugene Yokota c51c00bb3f Use app classpath for metabuild
Fixes #4437

Until now, sbt was resolved twice once by the launcher, and the second time by the metabuild.
This excludes sbt from the metabuild graph, and instead uses app classpath from the launcher.
2018-11-09 04:32:38 -05:00
Eugene Yokota c91371b7f8 add isMetaBuild setting
Fixes #3436

This implements isMetaBuild setting that is explicitly for meta build only,
unlike sbtPlugin setting which can be used for both meta build and plugin development purpose.
2018-11-09 03:08:47 -05:00
Ethan Atkins 7ec65f174d Close the current global file tree view on unload
I noticed that when using the latest nightly, triggered execution would
fail to work if I switched projects with, e.g. ++2.10.7. This was
because the background thread that filled the file cache was incorrectly shutdown.
To fix this, we just need to close whatever view is cached in the
globalFileTreeView attribute in the exit hook rather than the view
created by the method.

After making this change and publishing a local SNAPSHOT build, I was
able to switch projects with ++ and have triggeredExecution continue to
work.
2018-10-29 14:21:36 -07:00
Eugene Yokota f70ce9bab0 Set withMetadataDirectory by default
This partly fixes cached resolution.

Ref https://github.com/sbt/sbt/issues/3761
2018-10-15 03:26:39 -04:00
eugene yokota 1f8e9c9657
Merge pull request #4410 from eed3si9n/wip/semantic
ThisBuild / enableSemanticDB
2018-10-12 01:00:16 -04:00
Eugene Yokota aa8c1f484b implement SemanticdbPlugin
This makes it easier to enable SemanticDB build wide.
2018-10-11 15:44:15 -04:00
Andrea Peruffo a2607f1da6
Merge branch 'develop' into refactorCancellations 2018-10-11 18:57:57 +01:00
eugene yokota e759d17b2e
Merge pull request #4397 from andreaTP/lspCompletions
[sbt-server] LSP completions support
2018-10-11 12:49:23 -04:00
andrea 02b19752eb refactoring of server cancellation request 2018-10-11 14:03:41 +01:00
andrea 34e0fc159c [sbt-server] LSP completions support 2018-10-11 13:34:40 +01:00
Ethan Atkins f579b89577 Fix windows reload loop
On windows* it was possible to get into a loop where the build would
continually restart because for some reason the build.sbt file would get
touched during test (I did not see this behavior on osx). Thankfully,
the repository keeps track of the file hash and when we detect that the
build file has been updated, we check the file hash to see if it
actually changed.

Note that had this bug shipped, it would have been fixable by overriding
the watchOnEvent task in user builds.

The loop would occur if I ran ~filesJVM/test in
https://github.com/swoval/swoval. It would not occur if I ran
test:compile, so the fact that the build file is being touched seems
to be related to the test run itself.
2018-10-10 20:16:29 -07:00
Ethan Atkins d9e8ae18b2 Fix default FileTreeViewConfig
It was possible that on startup, when this function was first invoked,
that the default boot commands are present. This was a problem because
the global file repository is instantiated using the value of this task.
When we start a continuous build, this task gets run again to evaluate
again.

When sbt is started without an implicit task list, then the task is
implicitly shell as indicated by the command "iflast shell". We can use
this to determine whether or not to use the global file system cache or
not.
2018-10-10 18:35:30 -07:00
Ethan Atkins 0a9ae7b4b4 Use FileTreeRepository when interactive or continuous
Ideally we use the FileTreeRepository for interactive sessions by
default. A continuous build is effectively interactive, so I'd like that
case to also use the file tree repository. To avoid breaking scripted
tests, many of which implicitly expect file tree changes to be
instantaneously available, we set interactive to true only if we are not
in a scripted run, which can be verified by checking that the commands
contains "setUpScripted".
2018-10-09 21:52:38 -07:00
Ethan Atkins dc4f705500 Add support to rebuild a '~' task by pressing 'r'
Sometimes a user may want to rerun their task even if the source files
haven't changed. Presently this is a little annoying because you have to
hit enter to stop the build and then up arrow or <ctrl+r> plus enter to
rebuild. It's more convenient to just be able to press the 'r' key to
re-run the task.

To implement this, I had to make the watch task set up a jline terminal
so that System.in would be character buffered instead of line buffered.
Furthermore, I took advantage of the NonBlockingInputStream
implementation provided by jline to wrap System.in. This was necessary
because even with the jline terminal, System.in.available doesn't return
> 0 until a newline character is entered. Instead, the
NonBlockingInputStream does provide a peek api with a timeout that will
return the next unread key off of System.in if there is one available.
This can be use to proxy available in the WrappedNonBlockingInputStream.

To ensure maximum user flexibility, I also update the watchHandleInput Key to
take an InputStream and return an Action. This setting will now receive
the wrapped System.in, which will allow the user to create their own
keybindings for watch actions without needing to use jline themselves.

Future work might make it more straightforward to go back to a line
buffered input if that is what the user desires.
2018-10-09 12:09:42 -07:00
Ethan Atkins 25e97f99f5 Add custom external hooks
For projects with a large number of files, zinc has to do a lot of work
to determine which source files and binaries have changes since the last
build. In a very simple project with 5000 source files, it takes roughly
750ms to do a no-op compile using the default incremental compiler
options. After this change, it takes about 200ms. Of those 200ms, 50ms
are due to the update task, which does a partial project resolution*.

The implementation is straightforward since zinc already provides an api
for overriding the built in change detection strategy. In a previous
commit, I updated the sources task to return StampedFile rather than
regular java.io.File instances. To compute all of the source file
stamps, we simply list the sources and if the source is in fact an
instance of StampedFile, we don't need to compute it, otherwise we
generate a StampedFile on the fly. After building a map of stamped files
for both the sources files and all of the binary dependencies, we simply
diff these maps with the previous results in the changedSources,
changedBinaries and removedProducts methods.

The new ExternalHooks are easily disabled by setting
`externalHooks := _ => None`
in the project build.

In the future, I could see moving ExternalHooks into the zinc project so
that other tools like bloop or mill could use them.

* I think this delay could be eliminated by caching the UpdateResult so
long as the project doesn't depend on any snapshot libraries. For a
project with a single source, the no-op compile takes O(50ms) so caching
the project resolution would make compilation start nearly
instantaneous.
2018-10-09 12:09:42 -07:00
Ethan Atkins 1f996185e1 Only use a file repository for interactive sessions
I realized that using the cache has the potential to cause issues for
batch processing in CI if some tasks assume that a file created by one
task will immediately be visible in the other. With the cache, there is
typically on O(10ms) latency between a file being created and appearing
in the cache (at least on OSX). When manually running commands, that
latency doesn't matter.
2018-10-09 12:09:42 -07:00
Ethan Atkins b155ffb77b Add support for polling some directories
It is not always possible to monitor a directory using OS file system
events. For example, inotify does not work with nfs. To work around
this, I add support for a hybrid FileTreeViewConfig that caches a
portion of the file system and monitors it with os file system
notification, but that polls a subset of the directories. When we query
the view using list or listEntries, we will actually query the file
system for the polling directories while we will read from the cache for
the remainder. When we are not in a continuous build (~ *), there is no
polling of the pollingDirectories but the cache will continue to update
the regular directories in the background. When we are in a continuous
build, we use a PollingWatchService to poll the pollingDirectories and
continue to use the regular repository callbacks for the other
directories.

I suspect that #4179 may be resolved by adding the directories for which
monitoring is not working to the pollingDirectories task.
2018-10-09 12:09:42 -07:00
Ethan Atkins 2b2b84f589 Use FileTreeDataView to collect files
Now that we have the fileTreeView task, we can generalized the process
of collecting files from the view (which may or may not actually cache
the underlying file tree). I moved the implementation of collectFiles
and addBaseSources into the new FileManagement object because Defaults
is already too large of a file. When we query the view, we also need to
register the directory we're listing because if the underlying view is a
cache, we must call register before any entries will be available.
Because FileTreeDataView doesn't have a register method, I implement
registration with a simple implicit class that pattern matches on the
underlying type and only calls register if it is actually a
FileRepository.

A side effect of this change is that the underlying files returned by
collectFiles and appendBaseSources are StampedFile instances. This is so
that in a subsequent commit, I can add a Zinc external hook that will
read these stamps from the files in the source input array rather than
compute the stamp on the fly. This leads to a substantial reduction in
Zinc startup time for projects with many source files. The file filters
also may be applied more quickly because the isDirectory property (which
we check for all source files) is read from a cached value rather than
requiring a stat.

I had to update a few of the scripted tests to use the `1.2.0`
FileTreeViewConfig because those tests would copy a file and then
immediately re-compile. The latency of cache invalidation is O(1-10ms),
but not instantaneous so it's necessary to either use a non-caching
FileTreeView or add a sleep between updates and compilation. I chose the
former.
2018-10-09 12:09:42 -07:00
Ethan Atkins d31fae59f7 Add global file repository task
Every time that the compile task is run, there are potentially a large
number of iops that must occur in order for sbt to generate the source
file list as well as for zinc to check which files have changed since
the last build. This can lead to a noticeable delay between when a build
is started (either manually or by triggered execution) and when
compilation actually begins. To reduce this latency, I am adding a
global view of the file system that will be stored in
BasicKeys.globalFileTreeView.

To make this work, I introduce the StampedFile trait, which augments the
java.io.File class with a stamp method that returns the zinc stamp for
the file. For source files, this will be a hash of the file, while for
binaries, it is just the last modified time. In order to gain access to
the sbt.internal.inc.Stamper class, I had to append addSbtZinc to the
commandProj configurations.

This view may or may not use an in-memory cache of the file system tree
to return the results. Because there is always the risk of the cache
getting out of sync with the actual file system, I both make it optional
to use a cache and provide a mechanism for flushing the cache. Moreover,
the in-memory cache implementation in sbt.io, which is backed by a
swoval FileTreeRepository, has the property that touching a monitored
directory invalidates the entire directory within the cache, so the
flush command isn't even strictly needed in general.

Because caching is optional, the global is of a FileTreeDataView, which
doesn't specify a caching strategy. Subsequent commits will make use of
this to potentially speed up incremental compilation by caching the
Stamps of the source files so that zinc does not need to compute the
hashes itself and will allow for continuous builds to use the cache to
monitor events instead of creating a new, standalone FileEventMonitor.
2018-10-09 12:09:42 -07:00
Ethan Atkins 28fd4a1e61 Add the ability to halt watch on failure
There may be instances where the user may wish to stop the watch if an
error occurs running the task. To facilitate this, I add boolean
parameter, lastStatus, to watchShouldTerminate. The value is computed by
modifying the state used to run the task to have a custom onFailure
command. If the task fails, the returned state will have the onFailure
command will be enqueued at the head of the remaining commands. The
result of the task then becomes true if the custom onFailure is not
present in the remaining commands and false if it is. We don't actually
run this command, so it's just implemented with the identity function.

I also updated Watched.watch to return an Action instead of Unit. This
enables us to return a failed state if Watched.watch returns
HandleError.
2018-10-09 12:09:41 -07:00
Ethan Atkins 7d3d3c71d6 Refactor Watched
This commit reworks Watched to be more testable and extensible. It also
adds some small features. The previous implementation presented a number
of challenges:

1) It relied on external side effects to terminate the watch, which was
   difficult to test
2) It exposed irrelevant implementation details to the user in the
   methods that exposed the WatchState as a parameter.
3) It spun up two worker threads. One was to monitor System.in for user
   input. The other was to poll the watch service for events and write
   them to a queue. The user input thread actually broke '~console'
   because nearly every console session will hit the <enter> key, which
   would eventually cause the watch to stop when the user exited the
   console.

To address (1), I add the shouldTerminate method to WatchConfig. This
takes the current watch iteration is input and if the function returns
true, the watch will stop.

To address (2), I replace the triggeredMessage and watchingMessage keys
with watchTriggeredMessage and watchStartMessage. The latter two keys
are functions that do not take the WatchState as parameters. Both
functions take the current iteration count as a parameter and the
watchTriggeredMessage also has a parameter for the path that triggered
the build.

To address (3), I stop using the sbt.internal.io.EventMonitor and
instead use the sbt.io.FileEventMonitor. The latter class is similar to
the former except that it's polling method accepts a duration, which may
be finite or infinite) and returns all of the events that occurred since
it was last polled. By adding the ability to poll for a finite amount of
time, we can interleave polling for events with polling System.in for
user input, all on the main thread. This eliminates the two extraneous
threads and fixes the '~console' use case I described before.

I also let the user configure the function that reads from System.in via
the watchHandleInput method. In fact, this method need not read from
System.in at all since it's just () => Watched.Action. The reason that
it isn't () => Boolean is that I'd like to leave open the option for the
ability to trigger a build via user input, not just terminating the
watch. My initial idea was to add the ability to type 'r' to re-build in
addition to <enter> to exit. This doesn't work without integrating
jline though because the input is buffered. Regardless, for testing
purposes, it gives us the ability to add a timeout to the watch by
making handleInput return true when a deadline expires.

The tests are a bit wonky because I still need to rely on side effects
in the logging methods to orchestrate the sequence of file events that
I'd like to test. While I could move some of this logic into a
background thread, there still needs to be coordination between the
state of the watch and the background thread. I think it's easier to
reason about when all of the work occurs on the same thread, even if it
makes these user provided functions impure.

I deprecated all of the previous watch related keys that are no longer
used with the new infrastructure. To avoid breaking existing builds, I
make the watchConfig task use the deprecated logging methods if they are
defined in the user's builds, but sbt will not longer set the default
values. For the vast majority of users, it should be straightforward to
migrate their builds to use the new keys.  My hunch is that the of the
deprecated keys, only triggeredMessage is widely used (in conjunction
with the clear screen method) and it is dead simple to replace it with
watchTriggeredMessage.

Note: The FileTreeViewConfig class is not really necessary for this commit.
It will become more important in a subsequent commit which introduces an
optional global file system cache.
2018-10-08 22:00:50 -07:00
Ethan Atkins 28aa1de32a Refactor continuous execution
This commit makes watch event logging work in the '~' command. The
previous design of the command made this difficult, so there is a
significant re-design of the implementation of '~'. I believe that this
redesign will allow the feature to be maintained and improved more
easily moving forward. With the redesign, it is now possible to test the
business logic of the watch command (and I add a rudimentary test that I
will build upon in subsequent commits).

A bonus of this redesign is that now if the user tries to watch an
invalid command, the watch will immediately terminate with an error
rather than get stuck waiting for events when the task can never
possibly succeed.

The previous implementation of the '~' command makes it difficult
to dynamically control the implementation arguments because it is
implemented in the command project which makes it unable to depend on
any task keys that are defined in the build. It works around this by
putting all of it's configuration in the Watched attribute which is
stored globally. This would not have been necessary if the function had
been defined in the main project where it could just extract the value
of the watched task rather than relying on the global attribute value.
Moreover, because it cannot depend on tasks, it makes it nigh impossible
to use the logging framework within the '~' command.

Another issue with the previous implementation is that it's somewhat
difficult to reason about. The executeContinuously has effectively two
entry points: one for the first time the command is run and one for each
subsequent invocation when a new build is triggered. The successive
invocations are triggered by prepending commands to run to the previous
state. This is made recursive by prepending the initial command (that
was prefixed with '~'. Which branch we're in is determined by checking
for the existence of a temporary attribute, that we must ensure that we
remove when the build is stopped. This makes a lot of behavior non-local and
difficult for an outsider who is less familiar with sbt to understand.

Broadly, this refactor does two things:
1) Move the definition of continuous from BasicCommands to BuiltInCommands
2) Re-work the implementation to be executed in code rather than using
   the sbt dsl.

The first part is simple. We just add an implementation of continuous to
BuiltInCommands and remove it from the list of BasicCommands. We need to
leave in the legacy implementation for binary compatibility. I also
moved all of the actual implementation logic into Watched, which makes
maintenance easier since most of the logic is in one place.

The second part is more complicated. Rather than rely on the sbt dsl
(e.g. `(ClearOnFailure :: next :: FailureWall :: repeat :: s)`) to
parse and run the command. We manually parse the command and generate a
task of type `() => State`. We don't actually need to do anything with
the generated state because we're going to return the original state at
the end of the command no matter what. With this task, we can then
create a tail recursive function that repeatedly executes the task until
the watch is terminated.

The parsing is handled in the Watch.command method (which is where I
moved the refactored BasicCommands.continuous implementation). The
actual task running and monitoring is handled in Watched.watch. This
method has no reference to the sbt state, which makes it testable. It sets
up an event monitor and then delegates the recursive monitoring to a
small nested function, Watched.watch.impl. One nice thing about this
approach is that it is very easy to reason about the life cycle of the
EventMonitor. The recursive call is within a try { } finally { } where
the monitor and stdin are guaranteed to be cleared at the end.

Adding support for a custom (and default) watch logger is trivial with
the new infrastructure and is done via the watchLogger TaskKey.

There was a small reporting race condition that was introduced by the
change to (2). Because the new implementation is able to bypass command
parsing for triggered builds, the watch message would usually end up
being printed before the task outcome was fully logged. To work around
this, I made the watch and triggered messages be logged rather than
printed directly to stdout. As a result, the only user visible result of
this change should be that instead of seeing:
"1. Waiting for source changes in project foo... (press enter to interrupt)",
users will now see:
"[info] 1. Waiting for source changes in project foo... (press enter to interrupt)".
2018-10-08 22:00:50 -07:00
Ethan Atkins 5e3f72ad8a Do not append default watch sources with ++=
Using ++= prevents these from being overridden by the user without doing
some nasty runtime manipulations.
2018-10-08 22:00:50 -07:00
Ethan Atkins 97598efcea Bump watch anti-entropy
There have been reports that often a new build will be triggered
immediately after the previous build even when none of the files have
been modified since the start of the last build. This can happen when,
for example, a program implements save with a rename. When that occurs,
a deletion watch event may trigger the build but the corresponding
creation event may be detected outside of the current 40ms window. By
bumping this value to 500ms, we hopefully prevent the majority of these
false triggers. For unusual workflows in which this longer quarantine
period is an issue, the setting can be overridden.
2018-10-08 22:00:50 -07:00
Ethan Atkins 6ffb4108e7 Set swoval.tmpdir property on startup
This change makes the temporary shared library that is created by
the swoval file-tree-views library to be extracted into the sbt global
base directory rather than the temp file. This way if there is a leak of
shared libraries, they can easily be found in ~/.sbt rather than in,
say, /tmp (or the osx/windows equivalent location). The extracted shared
library objects will be in the path ~/.sbt/swoval-jni. There is a
shutdown hook that removes them as well as a garbage collection process
that runs in the background whenever the swoval library is loaded, so
these shouldn't leak uncontrollably.
2018-10-08 22:00:50 -07:00
Ethan Atkins aeadd8db72 Remove unneeded import 2018-10-08 13:59:40 -07:00
Ethan Atkins 6725b39a84 Bump io to 1.3.0-M3
I had to turn off -Xfatal-warnings in commandProj because after updating
io, commandProj depends on the deprecated EventMonitor class. In #4335,
I stop using EventMonitor, but deprecate the Watched class which is both
defined and used (as an unused attribute key) in commandProj. I think we
can probably get rid of Watched in 1.4.x and certainly in a hypothetical
2.x, so hopefully we can restore -Xfatal-warnings sooner than later.

I also had to replace uses of IO.classLocationFile with
IO.classLocationPath to avoid compilation failures due to
-Xfatal-warnings.
2018-10-08 13:59:34 -07:00
Eugene Yokota a9fd111143 Include both explicit plugin resolves and boot resolvers
Fixes #4408
2018-10-07 00:15:58 -04:00
eugene yokota 4867e87eca
Merge pull request #4396 from eed3si9n/wip/progress
"super shell" for sbt
2018-10-06 13:07:11 -04:00
Eugene Yokota c64166ea8d check PluginCross.scala consisntency 2018-10-05 13:32:40 -04:00
Eugene Yokota ca7c7d3841 Fix resolver for compiler bridge
I noticed that we can't resolve the compiler bridge out of snapshot repo.
2018-10-05 04:11:08 -04:00
Eugene Yokota 6dc27a3f6e change to DeleteLine 2018-10-02 08:25:28 -04:00
Eugene Yokota 1465604f8c Demote "Done updating." log to debug level 2018-10-02 08:25:28 -04:00
Eugene Yokota c316c80093 adds task progress
Fixes #4362

This implements an instance of ExecuteProgress that is enabled by default to report progress on the shell.
Combined with the scroll up logger, this takes over the bottom lines of the terminal screen and display a count up clock of the currently executing task.
2018-10-02 08:25:28 -04:00
eugene yokota e2923541b1
Merge pull request #4384 from andreaTP/lspCancellationSupport
Implementing cancellation requests for LSP server
2018-10-01 15:00:43 -04:00
andrea d7c55a3d82 Implementing cancellation requests for LSP server 2018-10-01 14:39:26 +01:00
Dale Wijnand b174a13b9c
Fix scaladoc for DslAggregate 2018-09-28 10:41:08 +01:00
eugene yokota 1fc0cd0314
Merge pull request #4377 from eed3si9n/wip/openjdk11
Scala 2.12.7 and linesIterator
2018-09-28 02:56:37 -04:00
Eugene Yokota 2389106aa6 Use linesIterator for JDK 11 compat 2018-09-27 12:41:47 -04:00
andrea 15d11f8f55 Fix: #4370 2018-09-25 12:57:09 +01:00
eugene yokota 550c068b98
Merge pull request #4369 from eed3si9n/wip/task-sequential
Implement sequential[B](tasks: Seq[Initialize[Task[B]]])
2018-09-19 23:19:16 -04:00
Yusuke Izawa b47ca1b9ef Implement sequential[B](tasks: Seq[Initialize[Task[B]]]) and remove useless comment outs 2018-09-19 20:54:18 -04:00
kai-chi 3f1ce8b9a0 expand tilde prefix 2018-09-19 18:35:59 +02:00
Eugene Yokota 3e1dac5161 -Xfatal-warnings in most subprojects 2018-09-18 11:47:55 -04:00
Eugene Yokota f2bc786fd1 cleaning up a few compiler warnings 2018-09-17 22:30:14 -04:00
eugene yokota 04a4456dd0
Merge pull request #4313 from raboof/supportJdk11AndJavaHomeInCrossJava
Support discovering JDK 11 in JAVA_HOME for CrossJava
2018-09-17 12:34:31 -04:00
eugene yokota 20573e8631
Merge pull request #4341 from Falmarri/feature/show-output-4184
Add `print` command that mimics `show`, but to standard output, not the logger
2018-09-17 12:33:25 -04:00
eugene yokota d3b79ae2e1
Merge pull request #4356 from eed3si9n/wip/remove-global-dir-warning
Remove old warning about global dir
2018-09-17 12:33:06 -04:00
eugene yokota 3f1ae8bd55
Merge pull request #4355 from eed3si9n/wip/one-letter
Allow single-letter aliases
2018-09-16 02:58:45 -04:00
eugene yokota 6b6c52b2d8
Merge pull request #4306 from sirocchj/fix-4236
Fixes #4236
2018-09-16 02:57:09 -04:00
Eugene Yokota f2f1d06329 Remove old warning about global dir
Fixes #1054
2018-09-16 01:55:18 -04:00
Eugene Yokota a2ef775edc Add scaladoc for Cross 2018-09-16 01:51:53 -04:00
falmarri cc143db6f7 Make `show` output on stdout rather than to the logger
Fixes #4184
2018-09-15 18:35:04 -07:00
eugene yokota 8af7a5acae
Merge pull request #4358 from eed3si9n/wip/license
Apache License 2.0
2018-09-14 11:11:17 -04:00
Eugene Yokota 4ff4f6e45e Update header 2018-09-14 04:53:36 -04:00
Eugene Yokota 426c31ae53 Follow up on Position extension
https://github.com/sbt/util/pull/173 added the ability to carry range position. This exposes it to the sbt server.
2018-09-14 00:59:21 -04:00
Eugene Yokota f3424e265c Formatting 2018-09-14 00:59:01 -04:00
Eugene Yokota 9ffae4e31f Allow single-letter aliases
Fixes #1074
2018-09-14 00:38:24 -04:00
Guillaume Martres 7eab02fff3 Add scalaCompilerBridgeBinaryJar task
The end goal is to rewrite Dotty's compiler-bridge in Java (this is easy
since the zinc-specific phases are in the compiler itself) to simplify
the bootstrapping process.
2018-09-13 16:13:45 -04:00
Guillaume Martres 0dc3f39ab2 Fix second part of #4091: server responses should not be broadcasted
Change CommandExchange#publishEvent to not broadcast ExecStatusEvent and
instead check the channelName, this matches what was already done in
CommandExchange#publishEventMessage
2018-09-05 18:34:03 +02:00
Eugene Yokota 590dc5e96d Merge branch '1.2.x' into wip/merge-1.2.x 2018-08-16 16:15:15 -04:00
eugene yokota f8beb5fcce
Merge pull request #4323 from jastice/dont-warn-version-override
don't warn when current sbt version doesn't match version in build.properties
2018-08-16 16:05:17 -04:00
Justin Kaeser a50e351c58 don't warn when current sbt version doesn't match version in build.properties when version is set by system property.
mitigates https://github.com/sbt/sbt/issues/4303
2018-08-16 18:01:54 +03:00
eugene yokota bb8bd7b0ca
Merge pull request #4308 from seratch/fix-typos
Fix the several typos detected by github.com/client9/misspell
2018-08-15 10:51:03 -04:00
Arnout Engelen bed2e11d59 Update test to reflect new WindowsDiscoverConfig ctor 2018-08-15 16:19:14 +02:00
Arnout Engelen b699f0fc6f Also look in (x86) 2018-08-15 11:21:30 +02:00
Arnout Engelen b1fc7dc183 Support discovering JDK 11 in JAVA_HOME for CrossJava 2018-08-09 14:43:11 +02:00
Kazuhiro Sera 59dbc0645e Fix the several typos detected by github.com/client9/misspell 2018-08-08 15:57:34 +09:00
Julien Sirocchi bb49018c52 Fixes #4236 2018-08-07 10:26:56 +01:00
eugene yokota 1ebc1a7bfc
Merge pull request #4302 from eed3si9n/wip/remove-configuration-warning
Remove warnings about configuration
2018-08-06 08:34:05 -04:00
Eugene Yokota 780ca366d8 Remove warnings about configuration
Fixes #4293
Ref #4231, #4065

This fixes the regression on sbt 1.2.0 that displays a lot of warnings about configurations.

The warning was added in #4231 in an attempt to fix #4065. This actually highlights somewhat loose usage of configurations among the builds in the wild, and the limitation on the current slash syntax implementation.

I think we can remove this warning for now, and try to fix #4065 by making slash syntax more robust. In particular, we need to memorize the mapping between the configuration name and Scala identifier across the entire build, and use that in the shell.
2018-08-06 00:22:57 -04:00
Eugene Yokota 26c180e768 Revert "Switch inThisBuild (+friends) to use varargs SettingsDefinition"
This reverts commit f459b218c4.
2018-08-05 16:00:33 -04:00
Eugene Yokota eac7eef947 Revert "Switch to varargs inThisBuild (+friends)"
This reverts commit ccf938c786.
2018-08-05 15:44:37 -04:00
Philippus 15e6cdfd68
Set default maven configurations in pom configuration, fixes #1380 2018-08-05 09:25:33 +02:00
Eugene Platonov cc2159d565 add human readable total time 2018-07-21 15:56:48 -04:00
Eugene Yokota 1bf6f0d2a0 Make ++ fail when it doesn't affect any subprojects
Fixes #4267
2018-07-15 20:47:59 -04:00
eugene yokota c02bc2f9d1
Merge pull request #4264 from eed3si9n/wip/javacrossfix
Fixes contains bug
2018-07-14 03:13:05 -04:00
Eugene Yokota 439e67c8c4 Fixes contains bug
Ref https://github.com/scala/bug/issues/10831
Ref https://github.com/sbt/sbt/pull/4139#commitcomment-29633458
2018-07-14 01:05:14 -04:00
Eugene Yokota 5c2c8b262a sbt-giter8-resolver 0.11.0 2018-07-13 17:53:37 -04:00
Eugene Yokota b3342118f8 Add dependencyOverrides for scripted-plugin
Fixes #4249

This introduces an override rule into the metabuild so scripted-plugin will align with the sbt version.
2018-07-10 03:13:47 -04:00
xuwei-k f22809d152 correspond file names and class names, packages and directories 2018-07-09 14:41:44 +09:00
xuwei-k ae1fdff968 use SAM type 2018-07-09 13:06:34 +09:00
xuwei-k aa14656753 fix typo 2018-07-08 22:18:57 +09:00
Jason Zaugg c10ff305de Defer deprecation warn of last-grep/load-failed until they are used 2018-07-04 08:49:26 +10:00
eugene yokota 8692952e91
Merge pull request #4245 from raboof/selectLatestJavaVersion
Select most recent JDK
2018-07-03 12:29:47 -04:00
Arnout Engelen 46693548d7 Add missing copyright header 2018-07-03 15:50:57 +02:00
Arnout Engelen 57e3183b8d Discover jvm installed via Oracle Linux RPM's 2018-07-03 15:29:31 +02:00
Arnout Engelen 7630ed8201 Select most recent jdk
When multiple jdk minor/patch versions are available, select the most
recent one.
2018-07-03 11:06:04 +02:00
eugene yokota 773d35dadd
Merge pull request #4231 from steinybot/fix/3432
Add warning for unknown configurations
2018-06-27 20:59:43 -04:00
eugene yokota b0e025915a
Merge pull request #4227 from eed3si9n/wip/thin
Implement thin client
2018-06-27 15:27:42 -04:00
Eugene Yokota 3b7e6974c3 Fixes stacktrace of backgroun run
Ref https://github.com/sbt/sbt/issues/4121

sbt already has the facility to trim stack traces. This sets the trace level of the background run, which fixes the upper half of the `run` stacktrace.

```
[error] (run-main-0) java.lang.Exception
[error] java.lang.Exception
[error] 	at Hello$.delayedEndpoint$Hello$1(Hello.scala:5)
[error] 	at Hello$delayedInit$body.apply(Hello.scala:1)
[error] 	at scala.Function0.apply$mcV$sp(Function0.scala:34)
[error] 	at scala.Function0.apply$mcV$sp$(Function0.scala:34)
[error] 	at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
[error] 	at scala.App.$anonfun$main$1$adapted(App.scala:76)
[error] 	at scala.collection.immutable.List.foreach(List.scala:389)
[error] 	at scala.App.main(App.scala:76)
[error] 	at scala.App.main$(App.scala:74)
[error] 	at Hello$.main(Hello.scala:1)
[error] 	at Hello.main(Hello.scala)
[error] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] 	at java.lang.reflect.Method.invoke(Method.java:498)
[error] java.lang.RuntimeException: Nonzero exit code: 1
[error] 	at sbt.Run$.executeTrapExit(Run.scala:127)
[error] 	at sbt.Run.run(Run.scala:77)
[error] 	at sbt.Defaults$.$anonfun$bgRunTask$5(Defaults.scala:1254)
[error] 	at sbt.Defaults$.$anonfun$bgRunTask$5$adapted(Defaults.scala:1249)
[error] 	at sbt.internal.BackgroundThreadPool.$anonfun$run$1(DefaultBackgroundJobService.scala:377)
[error] 	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error] 	at scala.util.Try$.apply(Try.scala:209)
[error] 	at sbt.internal.BackgroundThreadPool$BackgroundRunnable.run(DefaultBackgroundJobService.scala:299)
[error] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] 	at java.lang.Thread.run(Thread.java:748)
[error] (Compile / run) Nonzero exit code: 1
```

The bottom half requires a similar fix to the foreground log.
2018-06-27 06:26:38 -04:00
Jason Pickens c9aa0c5285 Add warning for unknown project configurations. 2018-06-27 18:25:10 +12:00
Eugene Yokota f3038167a5 Fork server if it's not running
Fixes https://github.com/sbt/sbt/issues/3508

This forks an instance of sbt in the background when it's not running already.

```
$ time sbt -client compile
Getting org.scala-sbt sbt 1.2.0-SNAPSHOT  (this may take some time)...
:: retrieving :: org.scala-sbt#boot-app
	confs: [default]
	79 artifacts copied, 0 already retrieved (28214kB/130ms)
[info] entering *experimental* thin client - BEEP WHIRR
[info] server was not detected. starting an instance
[info] waiting for the server...
[info] waiting for the server...
[info] server found
> compile
[success] completed
sbt -client compile  9.25s user 2.39s system 33% cpu 34.893 total
$ time sbt -client compile
[info] entering *experimental* thin client - BEEP WHIRR
> compile
[success] completed
sbt -client compile  3.55s user 1.68s system 107% cpu 4.889 total
```
2018-06-25 22:37:22 -04:00
Eugene Yokota 1a1f530985 implement -client option 2018-06-25 22:26:13 -04:00
Guillaume Poirier 59465d9e1f Adding minimal support for commands in inspect
There's also a special case for aliases that will try to resolve
the target of the alias to a task key if possible and display the
output of that key if found.

see https://github.com/sbt/sbt/issues/2881
2018-06-22 09:04:56 -04:00
eugene yokota a34f76bab7
Merge pull request #4220 from regadas/issue/630
Add alternative scripted filenames
2018-06-19 22:03:18 -04:00
Filipe Regadas 0fb07a861b Add alternative scripted filenames 2018-06-19 14:59:04 -04:00
Anthony Garo d62a7465ae Addresses #4206 2018-06-19 11:55:57 -04:00
eugene yokota 6fbb7f055a
Merge pull request #4211 from eed3si9n/wip/loadplugin
addPluginSbtFile command
2018-06-18 22:35:08 -04:00
Eugene Yokota 932f911483 addPluginSbtFile command
Fixes https://github.com/sbt/sbt/issues/1502

This adds `--addPluginSbtFile=<file>` command, which adds the given .sbt file to the plugin build.
Using this mechanism editors or IDEs can start a build with required plugin.

```
$ cat /tmp/extra.sbt
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.7")

$ sbt --addPluginSbtFile=/tmp/extra.sbt
...
sbt:helloworld> plugins
In file:/xxxx/hellotest/
  ...
  sbtassembly.AssemblyPlugin: enabled in root
```
2018-06-18 01:50:36 -04:00
Eugene Yokota b3bcb3f47d Open up setPlugins to private[sbt]
This would make it easier for projectMatrix to be a plugin.
2018-06-18 00:36:43 -04:00
eugene yokota f3618c74b6
Merge pull request #4205 from sbt/1.1.x
Merge 1.1.x
2018-06-15 15:33:02 -04:00
Eugene Yokota e3c9eb0cd9 Remove the shutdown hook when it's done 2018-06-14 05:12:36 -04:00
eugene yokota 9b8648519f
Merge pull request #4198 from eed3si9n/wip/offline-props
-Dsbt.offline sets offline setting
2018-06-14 01:09:32 -04:00
Eugene Yokota 7b6ae46116 -Dsbt.offline sets offline setting
Fixes #771
2018-06-13 03:52:21 -04:00
eugene yokota 54ad0d865e
Merge branch '1.x' into sort-and-indent-plugins-output 2018-06-13 03:21:02 -04:00
Eugene Yokota 86427c7ce7 Merge branch '1.1.x' into wip/merge-1.1.x 2018-06-12 23:33:47 -04:00
veera venky e465aee36a Fix for #4191 (active.json should be removed on JVM shutdown)
Added a shutdown hook to clean up active.json file
2018-06-13 03:06:30 +05:30
Mark Canlas 5fd774693c sort and indent about plugins output 2018-06-09 01:31:45 -04:00
Ethan Atkins 27e93601b5 Add warning for slow hostname lookups on OS X
I spent a lot of time debugging why it took 5 seconds to run tests each
time. It turns out that if the hostname is not set explicitly on os x,
then getaddrinfo takes 5 seconds to try (and fail) to resolve the dns
entry for the localhostname. This is easily fixed by setting the
hostname, but it is not at all easy to figure out that a slow hostname
lookup is the reason why tests are slow to start.

I don't know if this is a common issue on other platforms, so only issue
the warning on OS X.
2018-06-06 10:53:46 -07:00
Eugene Yokota 9b7c224f93 use stringly-typed key so we can define it machine-wide 2018-05-30 00:59:12 -04:00
Eugene Yokota a7d85c8724 Formatting 2018-05-30 00:16:27 -04:00
Eugene Yokota 35e98f51fd Adjust to upstream change 2018-05-30 00:16:27 -04:00
Eugene Yokota 2da1aa61eb implement cross JDK forking
```
sbt:helloworld> java++ 10
[info] Reapplying settings...
sbt:helloworld> run
[info] Running (fork) Hello
[info] 10.0.1

sbt:helloworld> java++ 8
[info] Reapplying settings...

sbt:helloworld> run
[info] Running (fork) Hello
[info] 1.8.0_171
```
2018-05-30 00:16:27 -04:00
Eugene Yokota aff9e0110c Accept both 1.x and x for 1.1 to 1.8 2018-05-30 00:16:27 -04:00
Martynas Mickevičius c31583e4f8 Discovery of java homes 2018-05-30 00:16:27 -04:00
Antonio Cunei f2a7e1f1c3 Fix for #4148 (SessionSettingsSpec intermittently fails)
It turns out that `syntaxAnalyzer.UnitParser()` in global now also
needs to be synchronized. The alternative is adding `synchronizeNames = true`
in the global constructor, but that already proved unreliable in the
case of #3743 (see comment https://github.com/sbt/sbt/issues/3170#issuecomment-355218833)
2018-05-28 14:09:13 +02:00
eugene yokota 7e8e18b9fa
Merge pull request #4099 from eatkins/redundant
Handle managedSources writing into unmanaged source directories
2018-05-27 23:57:46 -04:00
alodavi 67efea6248 [alodavi/improving_loading_settings_messaging] logging file and project name instead of only file name 2018-05-23 17:20:41 +02:00
Aloisia Davì 9b5f44f1ea
Merge branch '1.x' into alodavi/improving_loading_settings_messaging 2018-05-23 17:08:50 +02:00
Dale Wijnand ab35c21c98
Drop deprecated write-sbt-version & notify-users-about-shell
Introduced in https://github.com/sbt/sbt/pull/4169, these commands
aren't "user-facing" and are quite new. So no need to keep the old kebab
syntax.
2018-05-21 17:24:38 +01:00
tiqwab b7c9862f16 Fix kebab-case commands: notify-users-about-shell, write-sbt-version 2018-05-19 18:31:20 +09:00
Aloisia Davì 145da16c7f
Merge branch '1.x' into alodavi/improving_loading_settings_messaging 2018-05-15 14:53:00 +02:00
Øyvind Høisæther 667a6be99e Show all lines when running help <task>, but only first line when listing tasks 2018-05-15 14:33:24 +02:00
alodavi b30159aded [alodavi/improving_loading_settings_messaging] logging the path instead of just the name 2018-05-15 14:06:50 +02:00
Øyvind Høisæther 34cc8cd273 Only use first line for multiline descriptions 2018-05-15 13:42:41 +02:00
Alexander Samsig 7dfe6097fb Removed Load and LoadCommand since they are no longer in use.
Changed add-defaults-commands directly since it is only used internally.
Added deprecation warning for LoadFailed and LastGrep.
2018-05-15 12:44:17 +02:00
Eugene Yokota 90931857c3 Merge branch 'pr/4096' into wip/bumpzinc 2018-05-05 04:58:19 -04:00
Eugene Yokota 094c2c602d Formatting 2018-05-05 04:57:14 -04:00
Eugene Yokota 8409735077 Merge branch '1.1.x' into wip/merge-1.1.x 2018-05-04 12:40:43 -04:00
Liu Fengyun 1057dcd291 update deprecated message 2018-05-04 17:10:50 +02:00
Liu Fengyun 50f2ebce88 overload autoPlugins for binary compatibility 2018-05-04 17:00:25 +02:00
Liu Fengyun ecbfdfef25 fix compilation error 2018-05-03 22:36:17 +02:00
liu fengyun 5d63035a27 Fix #4073: support detect dotty plugins 2018-05-03 22:29:34 +02:00
Eugene Yokota 28e90ea09b Merge branch '1.1.x' into wip/merge-1.1.x 2018-04-29 14:31:30 -04:00
Seth Tisue 4477a42b5a upgrade Scala 2.12.4 -> 2.12.6
I have no specific user-visible benefit in mind other than fewer
JARs to download for people who are on current versions of things
2018-04-27 23:20:51 -04:00
Ethan Atkins 0de8345e33 Remove watch loops
When source generators write into the unmanaged source directory, bad
things can happen. Continuous builds will loop indefinitely and
compiling will fail because the generated sources get added to the
source list twice, causing the incremental compiler to complain about
compiling classes it has already seen. My two-pronged solution is to
de-duplicate the sources task and to filter out managed source files in
watch sources. The drawback to the latter is that it causes the source
generation task to be executed twice per compile.
2018-04-27 14:42:37 -07:00
Dale Wijnand a0e27c719c
Cleanup Resolve 2018-04-24 16:30:56 +01:00
Dale Wijnand 8f4b8abb7b
Run scalafmt & test:scalafmt 2018-04-24 16:12:10 +01:00
Ethan Atkins 754385125a Use new EventMonitor in executeContinuously
In https://github.com/sbt/io/pull/142, I add a new api for watching for
source file events. This commit updates sbt to use the new EventMonitor
based api. The EventMonitor has an anti-entropy parameter, so that
multiple events on the same file in a short window of time do not
trigger a build. I add a key to tune it.

The implementation of executeContinuously is pretty similar. The main
changes are that shouldTerminate now blocks (EventMonitor spins up a
thread to check the termination condition) and that the
EventMonitor.watch method only returns a Boolean. This is because
the event monitor contains mutable state. It does, however, have a
state() method that returns an immutable snapshot of the state.
2018-04-23 10:02:29 -07:00
Dale Wijnand a2af3bff15
Merge pull request #4098 from eatkins/filter
Exclude directories instead of including files
2018-04-23 08:15:11 +01:00
Dale Wijnand ccf938c786
Switch to varargs inThisBuild (+friends) 2018-04-19 22:34:52 +01:00
Dale Wijnand f459b218c4
Switch inThisBuild (+friends) to use varargs SettingsDefinition 2018-04-19 22:34:32 +01:00
Ethan Atkins 2bb717dbf9 Exclude directories instead of including files
The existing filter caused SourceModificationWatch.watch to ignore
deleted files because !file.exists implies !file.isFile. The intention
of the filter was to exclude directories that had a name ending in
".scala".
2018-04-13 11:36:40 -07:00
Alexey Alekhin a1e3146c08
Don't use initialize request id for the internal collectAnalyses call 2018-04-12 19:47:32 +02:00
Dale Wijnand 4fc45e0155
Merge pull request #4056 from BennyHill/fix/3042
Introduce CompositeProject
2018-04-09 11:30:17 +01:00
Nafer Sanabria 3e201cee4d Add lastGrep command 2018-04-08 10:56:25 -05:00
Alistair Johnson b0ad1a44c0 Remove projects parameter from CompositeProject.expand 2018-04-07 15:56:31 +02:00
Alistair Johnson 6cce4f6fd9 Remove duplicate Projects 2018-04-07 01:26:40 +02:00
Alistair Johnson 68c005e4b5 Ensure precedence of top level Projects over ComponentProjects 2018-04-07 01:04:45 +02:00
Jason Steenstra-Pickens 4dc76e2b38 Add dependencyResolution scoped to updateSbtClassifiers task
Fixes #3432
2018-04-06 10:41:31 +12:00
Alistair Johnson 03fc4ac686 Ensure unique project Id in composite projects 2018-04-04 21:01:05 +02:00
Alistair Johnson 77b536b25f Merge branch '1.x' of https://github.com/BennyHill/sbt into fix/3042
Conflicts:
	main/src/main/scala/sbt/internal/BuildDef.scala
	main/src/main/scala/sbt/internal/EvaluateConfigurations.scala
2018-04-04 18:30:56 +02:00
Dale Wijnand 9b3694e443
Merge pull request #4054 from eed3si9n/wip/repl
Fix console, JLine issue
2018-04-03 16:44:42 +01:00
Dale Wijnand d444b6b8ae
Merge pull request #4002 from eed3si9n/wip/opt-delegation-test
add tests around scope delegation
2018-04-03 16:43:09 +01:00
Alistair Johnson cbb953279c Intial implementation of CompositeProject 2018-03-31 20:28:09 +02:00
Eugene Yokota 88f50ce35d Fix console, JLine issue
Fixes #3482
2018-03-30 23:09:01 -04:00
Dale Wijnand 289077a405
Re-introduce Command.process
This was an unnecessary removal in
e83564a6b7.
2018-03-28 16:37:07 +01:00
Dale Wijnand 26c267e29e
Merge pull request #4043 from dwijnand/cleanup/ParseKey
Cleanup test/ParseKey
2018-03-28 16:10:03 +01:00
Dale Wijnand 25988d2256
Cleanup test/ParseKey 2018-03-28 09:04:12 +01:00
Eugene Yokota c2837c7714 Merge branch 'wip/bumpsbt' into wip/merge-1.1.x 2018-03-27 10:16:10 -04:00
Dale Wijnand b0f9fe77b6
Merge pull request #4036 from eed3si9n/wip/fix-startup-log
Fixes -error not suppressing startup logs
2018-03-26 15:28:50 +01:00
eugene yokota cd40d1ac77
Merge pull request #4031 from eed3si9n/wip/bump
bump modules
2018-03-26 10:26:25 -04:00
Eugene Yokota 25ab94d96a Fixes -error not suppressing startup logs
Fixes #3849

This brings back the 0.13 logic:

```scala
  def setGlobalLogLevel(s: State, level: Level.Value): State = {
    s.globalLogging.full match {
      case a: AbstractLogger => a.setLevel(level)
      case _                 => ()
    }
    s.put(BasicKeys.explicitGlobalLogLevels, true).put(Keys.logLevel.key, level)
  }
```
2018-03-25 14:56:00 -04:00
Eugene Yokota b111b05d5f Fixes new command leaving target directory
Fixes #2835

This fixes `new` command creating `target` directory by moving the `target` to a staging directory in the command itself.
2018-03-24 13:45:35 -04:00
Eugene Yokota 9d2d81645b bump modules 2018-03-24 11:02:40 +09:00
Dale Wijnand 00ce32f102
Cleanup CommandChannel 2018-03-20 09:17:55 +00:00
Dale Wijnand 6ceed00f48
Cleanup NetworkChannel 2018-03-19 15:11:39 +00:00
tmiyamon 77ffbe896d support test compile on saving in vscode 2018-03-16 18:03:52 +09:00
Dale Wijnand d3ef452a5f
Extract jsonRpcRespondErrorImpl 2018-03-15 12:55:21 +00:00
Dale Wijnand 268b5111ab
Format LSP methods 2018-03-15 12:55:21 +00:00
Dale Wijnand de690f4e41
Collapse 1-line scaladocs 2018-03-15 12:55:20 +00:00
Dale Wijnand 98332c0891
Reply to sbt/exec w/ a Response/Error w/ error code 2018-03-14 13:56:29 +00:00
Eugene Yokota 0433440c59 move ServerHandler to internal per review 2018-03-13 23:42:40 +09:00
Eugene Yokota cd9f0d2711 make sbt server extensible
Fixes #3890

Here's an example:

```scala
    Global / serverHandlers += ServerHandler({ callback =>
      import callback._
      import sjsonnew.BasicJsonProtocol._
      import sbt.internal.protocol.JsonRpcRequestMessage
      ServerIntent(
        {
          case r: JsonRpcRequestMessage if r.method == "lunar/helo" =>
            jsonRpcNotify("lunar/oleh", "")
            ()
        },
        PartialFunction.empty
      )
```
2018-03-13 23:02:45 +09:00
Eugene Yokota b82a1870a7 add tests around scope delegation 2018-03-10 17:24:39 -05:00
Dale Wijnand 80d342a811
Merge pull request #3995 from ruippeixotog/cross-strict-aggregation
Filter incompatible aggregates in cross switch commands
2018-03-08 11:27:55 +00:00
Dale Wijnand a85d7606f3
Merge pull request #3994 from fmlrt/in_configuration_scope_filter_factories
Add more configuration axis ScopeFilter factory methods
2018-03-08 11:26:38 +00:00
TATSUNO Yasuhiro 68f58aba87
Merge branch '1.x' into global-eviction-warning-options 2018-03-08 09:18:53 +09:00
exoego dc4f93a7c3 Remove unnecessary GlobalScope 2018-03-08 08:14:39 +09:00
Rui Gonçalves 251e5ab26e
Filter incompatible aggregates in cross switch commands 2018-03-07 00:27:22 +00:00
Maksym Fedorov 15f4498494 Add more configuration axis ScopeFilter factory methods 2018-03-06 23:01:31 +01:00
Dale Wijnand 685b416b8e
Cleanup Main 2018-03-06 11:59:26 +00:00
Dale Wijnand dbbba67d36
Fix a Scaladoc error in BuildStructure 2018-03-06 11:54:13 +00:00
Dale Wijnand 78f4f56d1c
Fix 2 "discarded non-Unit value" warnings in ScriptedPlugin 2018-03-06 11:54:12 +00:00
Dale Wijnand 9006abe9be
Cleanup ScriptedPlugin 2018-03-06 11:54:12 +00:00
Dale Wijnand 6e83d408da
Define ScriptedPlugin keys with macros 2018-03-06 11:54:11 +00:00
Dale Wijnand a73aa97b2c
Cleanup Extracted 2018-03-06 11:54:10 +00:00
exoego 36438d2ac3 Add eviction warnings options to global 2018-03-02 14:45:56 +09:00
Dale Wijnand 76e2f550ec
Merge branch '1.1.x' into merge-1.1.x-into-1.x
* 1.1.x:
  Update mimaPreviousArtifacts/sbt.version
  Introduce SBT_GLOBAL_SERVER_DIR env var to override too long paths
  Handle very long socket file paths on UNIX

Conflicts:
	project/build.properties
2018-02-14 14:38:07 +00:00
Dale Wijnand 4e038c91ce
Introduce SBT_GLOBAL_SERVER_DIR env var to override too long paths 2018-02-12 17:57:26 +00:00
Eugene Yokota 3db0e09b33 Merge branch '1.1.x' into wip/1.1.1
# Conflicts:
#	main/src/main/scala/sbt/internal/CommandExchange.scala
#	main/src/main/scala/sbt/internal/ConsoleProject.scala
#	notes/1.0.2/sample.md
#	notes/1.1.1/sample.md
#	notes/sample.md
#	sbt/src/test/scala/sbt/ServerSpec.scala
2018-02-09 23:55:23 -05:00
Dale Wijnand 8e7dfb4b20
Handle very long socket file paths on UNIX
Fixes #3930
2018-02-08 13:00:46 +00:00
eugene yokota 4a8adbb8e0
Merge pull request #3923 from dwijnand/PluginCross-scala-versions
Upgrade Scala versions that ^^ uses
2018-02-07 22:02:10 -05:00
eugene yokota 54eb6c2d6b
Merge pull request #3929 from eed3si9n/wip/servertest2
Backport server testing as a unit test
2018-02-07 21:18:35 -05:00
Eugene Yokota 3954985506 formatting 2018-02-07 18:16:02 -05:00
Eugene Yokota 5ab122c3cf Use State to pick the port file 2018-02-07 18:00:02 -05:00
Deokhwan Kim 11dbbd0cfa Update documentation for skip
'skip' is also supported for 'publish' by sbt/sbt#3380.
2018-02-07 00:32:03 -05:00
Steve Waldman 96b9429669 Rework false-defaulting 'suppressServer' to true-defaulting 'autoStartServer'. 2018-02-06 11:49:46 -08:00
Dale Wijnand 2db5c77442
Upgrade Scala versions that ^^ uses
Refs #3907
2018-02-06 16:02:45 +00:00
Steve Waldman 0aa133d276 Implement 'suppressServer' setting, for builds and plugins that prefer to be conservative about exposure to other processes. 2018-02-05 23:11:42 -08:00
Eugene Yokota 4b1de14f87 Use State to pick the port file 2018-01-30 23:46:12 -05:00
Dale Wijnand e3f33ddf7d
Merge pull request #3897 from dwijnand/misc
Misc tweaks and cleanups
2018-01-30 13:02:55 +00:00
Dale Wijnand 286758e2ba
Minor cleanups 2018-01-30 07:29:17 +00:00
eugene yokota 5d89795657
Merge pull request #3876 from eed3si9n/wip/jlineinit
Fix tab completion running `sbt console`
2018-01-22 14:14:35 -05:00
Eugene Yokota c20029ce16 Work around package name confusion
This works around the name conflict between sbt.test package and sbt.Keys.test.

1. sbt.test package is renamed to sbt.scriptedtest. This allows 1.0 plugins and builds to use `test` to mean `Keys.test`.
2. To keep binary compatibility for sbt 0.13 scripted, I am adding `sbt.test.ScriptedRunner` and `sbt.test.ScriptedTests` in `scripted-plugin` artifact.
3. Another affected user is Giter8 plugin that uses ScriptedPlugin. Since the intereactions are limited to `sbt.ScriptedPlugin.*`, we should be fine here. - https://github.com/foundweekends/giter8/blob/v0.11.0-M2/plugin/src/main/scala-sbt-1.0/giter8/SBTCompat.scala
2018-01-22 14:03:02 -05:00
Eugene Yokota b05802f63b move some scripted defaults settings to global
Fixes #3656
2018-01-22 14:03:02 -05:00
Eugene Yokota 08eaba9107 Add SbtPlugin
Fixes #3538

This brings in `sbt.ScriptedPlugin` as `sbt.plugins.ScriptedPlugin` into sbt mothership.
In addition, `sbt.plugins.SbtPlugin` is added that enables the scripted plugin and `sbtPlugin := true`.

This allows plugin authors to bring in scripted plugin by writing:

```scala
lazy val root = (project in file("."))
  .enablePlugins(SbtPlugin)
```
2018-01-22 14:02:06 -05:00
Eugene Yokota ca712acf41 Fix tab completion running `sbt console`
Fixes #3841

This fixes console task that internally uses JLine. When `console` is started from batch mode, the tab is printed as is. This is because JLine is not initialized yet.
Calling `usingTerminal` initializes and restores the terminal afterwards.
2018-01-16 15:41:48 -05:00
Dale Wijnand 113656aed1
Remove compile warnings 2018-01-16 11:17:01 +00:00
Dale Wijnand 0885233281
Deprecates Extracted#append for appendWithSession.
.. and appendWithoutSession.
2018-01-15 14:48:58 +00:00
Dale Wijnand a0b27d29b7
Merge pull request #3854 from sbt/1.1.x
1.1.x
2018-01-08 11:16:26 +00:00
Dale Wijnand 4752084f91
Introduce projectToLocalProject to replace projectToRef
Fixes #3757
2018-01-02 16:07:29 +00:00
Eugene Yokota 0aebb92ef5 don't block the build when server can't get up 2017-12-22 16:14:05 -05:00
Antonio Cunei 94e36a14c8 Change modifiedTime definitions 2017-12-22 01:55:37 +01:00
Antonio Cunei ebff7919e9 Revert *ModifiedTime() calls to *lastModified*() calls
There are just too many instances in which sbt's code relies on
the `lastModified`/`setLastModified` semantics, so instead of moving
to `get`/`setModifiedTime`, we use new IO calls that offer the new
timestamp precision, but retain the old semantics.
2017-12-22 01:55:37 +01:00
Dale Wijnand fd8b422488
Merge pull request #3760 from mpollmeier/mpollmeier/resolver-not-needed-if-not-publishing
don't require publishTo specified if publishArtifact is `false`
2017-12-21 15:40:17 +00:00
Eugene Yokota 13e1862c2f set jna.nosys to true programmatically
Previously I was seeing the error upon the first scripted test. I thought it was because Main was somehow not early enough. It might just be because scripted technically runs as part of the build.

Ref sbt/io#110
2017-12-21 00:08:56 -05:00
Eugene Yokota d8609ced7f formatting 2017-12-20 22:36:07 -05:00
Eugene Yokota 06ffb4f440 warn about multiple instance once
Fixes #3823

When you launch a second instance of sbt on a build, prior to this change it was displaying `java.io.IOException: sbt server is already running` on every command. This make it a bit less aggressive, and just display a warning once.

```
[warn] Is another instance of sbt is running on this build?
[warn] Running multiple instances is unsupported
```
2017-12-20 10:09:03 -05:00
eugene yokota 34d311f9ce
Merge pull request #3807 from dwijnand/remove-warnings
Remove warnings
2017-12-19 13:18:59 -05:00
eugene yokota bff933aceb
Merge pull request #3815 from dwijnand/drop-0.14-references
Drop 0.14.0 references
2017-12-18 20:55:34 -05:00
eugene yokota de4af16434
Merge pull request #3818 from sbt/1.1.x
Merge 1.1.x to 1.x
2017-12-18 20:55:11 -05:00
eugene yokota e40ab026c0
Merge pull request #3816 from eed3si9n/wip/bump
Convert lastModified() calls to the more precise getModifiedTime() + modules bump
2017-12-16 13:19:02 -05:00
Dale Wijnand ae99922101 Use IO.getModified over importing the method 2017-12-16 12:22:42 -05:00
Antonio Cunei 8c7b781d3f Moved Milli._ to IO. 2017-12-16 12:22:42 -05:00
Antonio Cunei 699b53262a Convert lastModified() to sbt.io.Milli.getModifiedTime(), more precise 2017-12-16 12:22:42 -05:00
Dale Wijnand fa2c48ed84
Drop 0.14.0 references
Fixes #3411
2017-12-15 15:44:21 +00:00
Michael Pollmeier 4668faff7c
don't require publishTo specified if publishArtifact is `false`
Even with `publishArtifact := false` the user is still forced to define a (dummy) resolver that's never used, e.g. `publishTo := { Some("publishMeNot" at "https://publish/me/not") }`

Otherwise the following error is thrown:
```
publish
[error] java.lang.RuntimeException: Repository for publishing is not specified.
[error]         at scala.sys.package$.error(package.scala:27)
[error]         at sbt.Classpaths$.$anonfun$getPublishTo$1(Defaults.scala:2436)
[error]         at scala.Option.getOrElse(Option.scala:121)
[error]         at sbt.Classpaths$.getPublishTo(Defaults.scala:2436)
[error]         at sbt.Classpaths$.$anonfun$ivyBaseSettings$48(Defaults.scala:1917)
```
2017-12-15 10:53:29 +00:00
Dale Wijnand 8bd522511d
Make CaffeineCache a lazy val
This is to avoid it initialising Log4J2 (via SLF4J), which we initialise
ourselves programmatically in LogExchange. Also there's no need to
removeAll in initialState.

Fixes #3787
2017-12-15 08:55:55 +00:00
Dale Wijnand 5f0852818b
Add project id to watching message
We redefine watchingMessage in project scope so we can use
thisProjectRef to make the watching message more precise.

Fixes #2038
2017-12-15 01:49:14 +00:00
Dale Wijnand a90832b593
Remove all warnings from mainProj 2017-12-14 15:40:03 +00:00
Dale Wijnand f50260218d
Remove all warnings from actionsProj 2017-12-14 13:19:23 +00:00
Dale Wijnand 2390fdfac6
Remove all warnings from mainSettingsProj 2017-12-14 13:16:23 +00:00
Dale Wijnand 2e5aabb222
Merge pull request #3805 from eed3si9n/wip/file_uri
Encode POSIX file path to URI using u3 (file:///)
2017-12-12 17:32:42 +00:00
Eugene Yokota 06b85919ba
Encode POSIX file path to URI using u3 (file:///)
Ref https://github.com/sbt/io/pull/96

Under RFC 8089, both u1 and u3 are legal, but many of the other platforms expect traditional u3.
This will increase the compatibility/usability of sbt server, for example to integrate with Vim.
2017-12-12 16:27:14 +00:00
Antonio Cunei 5c72c3b487 Revert "Alt scala parser sync workaround"
Although in theory the fix in #3776 should be preferable to
synchronize templateStats() manually, it turns out that we
still get errors in some tests. So, reverting to a
synchronized section while we investigate.

This reverts commit ee90917cc4.
2017-12-08 19:21:14 +01:00
Eugene Yokota 2b2c1f0568 prevent "shutdown" when server didn't come up 2017-12-05 08:04:59 -05:00
Eugene Yokota 93b3391167 Fixes server log hardcoded to debug level
Fixes #3786

To configure the log level of the server, this introduces a new task key named `serverLog`. The idea is to set this using `Global / serverLog / logLevel`. It will also check the global log level, and if all else fails, fallback to Warn.

```
    lazy val level: Level.Value = (s get serverLogLevel) orElse (s get logLevel) match {
      case Some(x) => x
      case None    => Level.Warn
    }
```
2017-12-02 15:20:54 -05:00
Eugene Yokota c5d578815c catch IOException intead of SocketException
`NGUnixDomainSocket` throws `java.io.IOException` instead of `SocketException`, probably because `SocketException` does not expose the contructor with a `Throwable` parameter.
To allow clients to disconnect, we need to catch `IOException`.
2017-11-29 22:42:58 -05:00
Eugene Yokota a6eb1260c8 Merge branch '1.0.x' into wip/bump 2017-11-29 16:45:02 -05:00
Eugene Yokota 6a996378c7 return Either[String, JsonRpcMessage] 2017-11-29 01:00:46 -05:00
Eugene Yokota e4dd090d0c Add debug log on unhandled notification 2017-11-29 00:51:16 -05:00
Alexey Alekhin c689821383 Added deserialization for NotificationMessage and used it in handleBody 2017-11-29 00:46:18 -05:00
Alexey Alekhin 36e079d12b Added onNotification handler for the LSP CommandChannel 2017-11-29 00:46:18 -05:00
wpopielarski 452e97e41d Adds backticks to class/trait/object name.
Adapts tests to changed specs2 dependency.

Tiny fixes.

Removes Scala IDE compiler clues.
2017-11-28 13:27:15 -05:00
wpopielarski 73b0034cfc textDocument/definition for LSP / VS Code
This is an implementation of `textDocument/definition` request.
Supports types only, and only in case when type is found in Zinc Analysis. When source(s) are found then editor opens potential source(s).
This simple implementation does not use semantic data.

During the processing of `textDocument/didSave`, we will start collecting the location of Analysis files via `lspCollectAnalyses`.
Later on, when the user asked for `textDocument/definition`, sbt server will invoke a Future call to lspDefinition, which direct reads the files to locate the definition of a class.
2017-11-28 13:27:07 -05:00
Dale Wijnand 297fd5d24b
Merge pull request #3742 from eed3si9n/wip/socket
IPC Unix domain socket / Windows named pipe
2017-11-28 16:04:11 +00:00
Dale Wijnand ee90917cc4
Alt scala parser sync workaround
Apply retronym's suggestion at https://github.com/scala/bug/issues/10605
instead of the workaround merged in https://github.com/sbt/sbt/pull/3743.
2017-11-28 12:00:38 +00:00
Eugene Yokota f785750fc4 IPC Unix domain socket for sbt server
In addition to TCP, this adds sbt server support for IPC (interprocess communication) using Unix domain socket and Windows named pipe.

The use of Unix domain socket has performance and security benefits.
2017-11-27 21:37:31 -05:00
eugene yokota e6165464ba
Merge pull request #3740 from laughedelic/wip/logmessage
LSP: improve logMessage notifications
2017-11-27 20:51:50 -05:00
xuwei-k 6b4093dc15 update specs2 4.0.1 2017-11-26 13:59:50 +09:00
xuwei-k 8ee413778a fix #3591. "Not a valid key: console-quick" 2017-11-23 14:56:52 +09:00
Dale Wijnand 8fe38d4a5a
Merge pull request #3743 from cunei/wip-flakyTests1
Workaround for scala/bug#10605
2017-11-16 10:58:53 +00:00
Antonio Cunei a050b73a46 Workaround for scala/bug#10605
templateStats() is not thread-safe in 2.12.x (at least up to 2.12.4)
2017-11-15 05:27:31 +01:00
Alexey Alekhin 0c0e0ce912 Log StringEvents and MessageEvents to the LSP client 2017-11-14 21:53:29 +01:00
Alexey Alekhin 6b6047b55c Publish ExecStatusEvent taking into account its channel name 2017-11-14 21:53:15 +01:00
OlegYch 6e29a1aa15 Improve testQuick performance, restoring caching of stamps 2017-11-07 22:56:05 -05:00
Antonio Cunei 1ca266d0f8 Do not always use Level.Debug while creating a backgroundLog
The creation of a backgroundLog was always using Debug as the
logging level for console and backing. This commit sets the
levels to those used by the caller. Fixes #3655
2017-11-06 15:33:05 +01:00
Dale Wijnand bb6d8d62ec
Merge pull request #3672 from RomanIakovlev/1.x
Add new setting to determine if running in CI env
2017-10-28 00:28:44 +01:00
Roman Iakovlev 69ae4f3073 Add a check for a change in SBT version before reload
Fixes #1055
2017-10-27 20:38:23 +02:00
Roman Iakovlev 5f143434a8 Add new setting to determine if running in CI env
Fixes #3653
2017-10-26 20:59:04 +02:00
Dale Wijnand 9f1d60be60
Rewrite to polymorphic function syntax 2017-10-25 10:23:46 +01:00
eugene yokota 8eb5879101 Merge pull request #3659 from eed3si9n/wip/reboot
Adds "reboot dev"
2017-10-25 04:06:59 -04:00
Eugene Yokota 6ac4571197 Adds "reboot dev"
This adds a new option `dev` to the `reboot` command, which deletes the only the current sbt artifacts from the boot directory. `reboot dev` reads actively from `build.properties` instead of using the current state since `reboot` can restart into another sbt version.

In general, `reboot dev` is intended for the local development of sbt.

Fixes #3590
2017-10-25 03:19:10 -04:00
Dale Wijnand 81c5eaec33 Merge pull request #3633 from dwijnand/misc-2017-10-12
Misc 2017-10-12
2017-10-24 20:37:20 +01:00
Dale Wijnand 78c5ee92d3
Track sources in base directory non-recursively
Using a recursive Source meant that ~ looked into target. If you have
any source generators and use ~ with anything the invokes them, like
~compile, that means that the act of generating sources triggers ~ to
re-execute compile (perhaps only on macOS where the NIO WatchService
just polls, after an initial delay).

Requires sbt/io#78

Fixes #3501
2017-10-24 11:09:00 +01:00
PanAeon 64241e0d3a Fixes #3464. Escape imports from sbt files, so if user creates a backquoted definition then task evalution will not fail. 2017-10-13 11:04:15 +01:00
Dale Wijnand 10397926aa
Make sure of EvaluateTask in Extracted obvious 2017-10-12 15:36:05 +01:00
eugene yokota fa33b6e422 Merge pull request #3632 from dwijnand/trailing-println
Kill trailing println
2017-10-11 13:38:09 -04:00
Dale Wijnand d8e52bb5d4
Kill trailing println 2017-10-11 15:29:15 +01:00
eugene yokota 8c04b267bf Merge branch '1.x' into 1.0.x 2017-10-10 10:57:05 -04:00
Michael Stringer b9a4d32916 Add system property to revert to old polling fs watcher
This adds a sbt.watch.mode system property that if set to 'polling' will
use PollingWatchService instead of WatchServiceAdapter (nio).

On macOS this will default to 'polling' and on all others 'nio'.

This is a temporary workaround for users affected by #3527
2017-10-10 01:17:42 -04:00
Michael Stringer a3c34c6c0a
Add system property to revert to old polling fs watcher
This adds a sbt.watch.mode system property that if set to 'polling' will
use PollingWatchService instead of WatchServiceAdapter (nio).

On macOS this will default to 'polling' and on all others 'nio'.

This is a temporary workaround for users affected by #3527
2017-10-09 18:01:33 +01:00
Eugene Yokota 5c394e18f6 implement window/logMessage
This sends sbt's log message as "window/logMessage" event to LSP.
2017-10-08 01:51:27 -04:00
Dale Wijnand f22843f91c
Move SlashSyntax to the settings component 2017-10-06 09:52:34 +01:00
eugene yokota 201a8031de Merge pull request #3609 from dwijnand/ref
Correct handling of resolving ThisProject
2017-10-05 15:39:24 -04:00
eugene yokota 5a6a651b8f Merge pull request #3604 from dwijnand/dedup-cmds-lists
Dedup DefaultCommands and allBasicCommands
2017-10-05 15:36:37 -04:00
Dale Wijnand f4b2fc4228
Correct handling of resolving ThisProject
In ca71b4b902 I went about fixing the
inexhaustive matching in Scope's resolveProjectBuild and
resolveProjectRef. Looking back the change was wrong.

For resolveProjectBuild the new implementation is less wrong, but still
not great, seeing as it doesn't actually do any build resolving.

For resolveProjectRef the new implementation now blows up instead of
lies. Which means it's less leneant, more "fail-fast".

isProjectThis is unused; remnant of the pre-AutoPlugin days when build
settings where defined in Plugin.settings.
2017-10-05 19:00:48 +01:00
Dale Wijnand 68129e6782
Dedup DefaultCommands and allBasicCommands
The command component's BasicCommands.allBasicCommands is a subset of
main component's BuiltinCommands.DefaultCommands, so I deduplicated.
2017-10-05 09:14:01 +01:00
Dale Wijnand a41727fb17
Add, configure & enforce file headers 2017-10-05 09:03:40 +01:00
Dale Wijnand dae4694f46 Merge pull request #3603 from eed3si9n/wip/zerozerozero
Fixes Zero / Zero / Zero / name handling
2017-10-05 08:59:30 +01:00
Eugene Yokota 60f2498c0a Implement toString for keys
toString added for REPL testing:

```
scala> Zero / Zero / Zero / name
res0: sbt.SlashSyntax.ScopeAndKey[sbt.SettingKey[String]] = Zero / Zero / Zero / name
```
2017-10-05 02:46:09 -04:00
Eugene Yokota 53bbb99617 Fixes Zero / Zero / Zero / name handling
Prior to this change `Zero / Zero / Zero / name` broke as folllows:

```
scala> Zero / Zero / Zero / name
Zero / Zero / Zero / name
<console>:18: error: inferred type arguments [sbt.Zero.type] do not conform to method /'s type parameter bounds [K <: sbt.SlashSyntax.Key[K]]
       Zero / Zero / Zero / name
                   ^
```
2017-10-05 02:43:50 -04:00
Dale Wijnand 530c405b2f
Implement Project#withId 2017-10-04 13:54:37 +01:00
Dale Wijnand d997fe8043
Oneline mkGeneratedRoot 2017-10-04 13:42:30 +01:00
Dale Wijnand ccdd77a94f
Remove old, commented out Project.apply 2017-10-04 13:42:29 +01:00
Dale Wijnand 1685dae1d9
Oneline Project.apply 2017-10-04 13:42:29 +01:00
Dale Wijnand ceb0f0228a
Use copy2 in resolveBuild 2017-10-04 13:42:29 +01:00
Dale Wijnand 9e855ffb55
Resolve some TODOs by creating a private copy2 in Project 2017-10-04 13:42:28 +01:00
eugene yokota 7af716f37b Merge pull request #3524 from eed3si9n/wip/language_server
language server protocol (VS Code integration)
2017-10-03 11:56:26 -04:00
Dale Wijnand 5c7461ada8 Merge pull request #3596 from dwijnand/slash
Cleanup and improve the unified slash syntax
2017-10-03 13:37:20 +01:00
Eugene Yokota 1ad9360e3e setting query is "sbt/setting" 2017-10-03 01:45:06 -04:00
Eugene Yokota a8e770c446 handle exec as "sbt/exec" 2017-10-03 00:18:58 -04:00
Eugene Yokota f188e60d8f Update test 2017-10-02 17:12:15 -04:00
Eugene Yokota 4fe0d08ab0 substitute println with logger 2017-10-02 15:42:55 -04:00
Dale Wijnand e7b893fdc5
Cleanup and improve the unified slash syntax 2017-10-02 17:24:37 +01:00
Eugene Yokota 0c1c380f71 begins language server protocol
This is the first cut for the Language Server Protocol on top of server that is still work in progress.

With this change, sbt is able to invoke `compile` task on saving files in VS Code.
2017-10-02 04:01:13 -04:00
Age Mooij 30e81398fd Removed unused local val 2017-09-28 13:37:38 +02:00
Dale Wijnand 21bd7c3a91 Merge pull request #3434 from eed3si9n/wip/slash
Unify sbt shell and build.sbt syntax (unified slash syntax redux)
2017-09-28 09:26:25 +01:00
Eugene Yokota b0306b738e Add whitespaces in Show of scoped keys
```
Provided by:
    ProjectRef(uri("...."), "root") / Test / test
Dependencies:
    Test / executeTests
    Test / test / streams
    Test / state
    Test / test / testResultLogger
```
2017-09-28 03:34:49 -04:00
Eugene Yokota 33a01f3ceb Unified slash syntax
Fixes sbt/sbt#1812

This adds unified slash syntax for both sbt shell and the build.sbt DSL.
Instead of the current `<project-id>/config:intask::key`,
this adds `<project-id>/<config-ident>/intask/key` where <config-ident> is the Scala identifier notation for the configurations like `Compile` and `Test`.

This also adds a series of implicits called `SlashSyntax` that adds `/` operators to project refererences, configuration, and keys such that the same syntax works in build.sbt.

These examples work for both from the shell and in build.sbt.

    Global / cancelable
    ThisBuild / scalaVersion
    Test / test
    root / Compile / compile / scalacOptions
    ProjectRef(uri("file:/xxx/helloworld/"),"root")/Compile/scalacOptions
    Zero / Zero / name

The inspect command now outputs something that can be copy-pasted:

    > inspect compile
    [info] Task: sbt.inc.Analysis
    [info] Description:
    [info] 	Compiles sources.
    [info] Provided by:
    [info] 	ProjectRef(uri("file:/xxx/helloworld/"),"root")/Compile/compile
    [info] Defined at:
    [info] 	(sbt.Defaults) Defaults.scala:326
    [info] Dependencies:
    [info] 	Compile/manipulateBytecode
    [info] 	Compile/incCompileSetup
    [info] Reverse dependencies:
    [info] 	Compile/printWarnings
    [info] 	Compile/products
    [info] 	Compile/discoveredSbtPlugins
    [info] 	Compile/discoveredMainClasses
    [info] Delegates:
    [info] 	Compile/compile
    [info] 	compile
    [info] 	ThisBuild/Compile/compile
    [info] 	ThisBuild/compile
    [info] 	Zero/Compile/compile
    [info] 	Global/compile
    [info] Related:
    [info] 	Test/compile
2017-09-28 01:01:43 -04:00
Alexey Alekhin 632b14cf78 Changed default version setting to 0.1.0-SNAPSHOT
To make it compatible with semantic versioning. Fixes #3467.
2017-09-25 15:06:17 +02:00
Eugene Yokota 348a077797 implement tokenfile authentication 2017-09-21 23:05:48 -04:00
Justin Kaeser 45d69f3762 Pass `allJars` when creating ScalaInstance instead of `otherJars`.
Fixes https://github.com/sbt/sbt/issues/3560
required for https://youtrack.jetbrains.com/issue/SCL-12591
2017-09-19 19:12:59 +02:00
Eugene Yokota 8a8215cf1b Use uri instead of url 2017-09-18 23:07:29 -04:00