Commit Graph

42 Commits

Author SHA1 Message Date
xuwei-k 6c032b8283 some trivial refactoring
- remove unused type params
- use `withFilter` if possible
- use `collectFirst` instead of `collect` and `headOption`
- use `length` instead of `size` if `Array` or `String`
- use `foreach` instead of `map`
2023-06-25 08:57:41 +09:00
Julien Richard-Foy 72bfb3f45a Transfer copyright to Scala Center 2023-06-20 16:39:07 +02:00
xuwei-k 535b15b83e fix Scala 2.13 warnings 2021-11-14 22:59:34 +09:00
Eugene Yokota 8f5759e48d Cross build to Scala 2.13 2021-01-10 20:24:05 -05:00
João Ferreira dd411cac9f introduce a new new Input/Output: FileInput/FileOutput
* FileInput avoids the intermediate String parsing of PlainInput
* FileOuput also avoid the intermediate String representation of PlainOutput
2020-11-25 14:04:56 +00:00
Eugene Yokota 2feecf8a1f Selective functor
This implements Selective functor for `Either[A, B]` "task" (`Initialize[Task[Either[A, B]]]`).
The selective functor allows an encoding of if-expression:

```
  def ifS[A](
      x: Def.Initialize[Task[Boolean]]
  )(t: Def.Initialize[Task[A]])(e: Def.Initialize[Task[A]]): Def.Initialize[Task[A]]
```

The benefit of this approach is that task dependencies are still visible to inspect command.
2020-05-17 23:36:04 -04:00
Jason Zaugg 43cc55a24c Avoid tens of thousands of duplicated "TypeFuntions.const(())" strings 2020-05-09 13:02:16 -04:00
Eugene Yokota 54b3405f42 apply -Yno-lub
To demonstrate [-Yno-lub](http://eed3si9n.com/stricter-scala-with-ynolub), this shows the code changes that removes lubing (Not all subprojects are done).

After I made the changes, I switched the Scala back to normal 2.12.10.
2019-10-13 23:46:23 -04:00
Ethan Atkins af16d33700 Add per file stream locks
We have seen failures in scripted to create the output file for streams
and it has also been reported in https://github.com/sbt/sbt/issues/5067.
I believe this may caused by the same stream output being initialized by
multiple tasks. To fix this, I add locking on a per-file basis. There
was (and is) additional synchronization on the Streams _instance_, but
the per-file locks are stored in the Streams companion object so the
locking should be honored no matter which Streams instance calls make.

I also skip the call to IO.touch if the file already exists. I believe
that this is the common case and since IO.touch was being called with
setModified = false, it should be fine to skip the touch when the file
exists.

Prior to this change, I was able to induce the issue in #5067 in roughly
1/50 of calls to `scripted actions/cross-multiproject`. I wasn't able to
reproduce after this change.
2019-09-14 15:22:05 -07:00
xuwei-k dfe789d7c6 avoid deprecated /: and :\
use foldLeft and foldRight

https://github.com/scala/scala/blob/v2.13.0/src/library/scala/collection/IterableOnce.scala#L682-L686
2019-08-30 11:20:53 +09:00
Ethan Atkins cad89d17a9 Add support for in memory cache store
It can be quite slow to read and parse a large json file. Often, we are
reading and writing the same file over and over even though it isn't
actually changing. This is particularly noticeable with the
UpdateReport*. To speed this up, I introduce a global cache that can be
used to read values from a CacheStore. When using the cache, I've seen
the time for the update task drop from about 200ms to about 1ms. This
ends up being a 400ms time savings for test because update is called for
both Compile / compile and Test / compile.

The way that this works is that I add a new abstraction
CacheStoreFactoryFactory, which is the most enterprise java thing I've
ever written. We store a CacheStoreFactoryFactory in the sbt State.
When we make Streams for the task, we make the Stream's
cacheStoreFactory field using the CacheStoreFactoryFactory. The
generated CacheStoreFactory may or may not refer to a global cache.

The CacheStoreFactoryFactory may produce CacheStoreFactory instances
that delegate to a Caffeine cache with a max size parameter that is
specified in bytes by the fileCacheSize setting (which can also be set
with -Dsbt.file.cache.size). The size of the cache entry is estimated by
the size of the contents on disk. Since we are generally storing things
in the cache that are serialized as json, I figure that this should be a
reasonable estimate. I set the default max cache size to 128MB, which is
plenty of space for the previous cache entries for most projects. If the
size is set to 0, the CacheStoreFactoryFactory generates a regular
DirectoryStoreFactory.

To ensure that the cache accurately reflects the disk state of the
previous cache (or other cache's using a CacheStore), the Caffeine cache
stores the last modified time of the file whose contents it should
represent. If there is a discrepancy in the last modified times (which
would happen if, say, clean has been run), then the value is read from
disk even if the value hasn't changed.

* With the following build.sbt file, it takes roughly 200ms to read and
parse the update report on my compute:

libraryDependencies += "org.apache.spark" %% "spark-sql" % "2.4.3"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1"

This is because spark-sql has an enormous number of dependencies and the
update report ends up being 3MB.
2019-07-11 17:45:16 -07:00
Dale Wijnand 5036f339f8
Remove unused Task#mapTask 2019-05-29 14:43:42 +01:00
Eugene Yokota 1e157b991a apply formatting 2019-04-20 03:23:54 -04:00
Ethan Atkins a556fc654a Lint Transform.scala
The file is green in intellij after this change.
2019-01-31 10:53:07 -08:00
Ethan Atkins da1cc40314 Rename System.scala to Transform.scala
The System.scala contained a single scala object called Transform, hence
the rename to Transform.scala.
2019-01-31 10:52:43 -08:00
Eugene Yokota 4ff4f6e45e Update header 2018-09-14 04:53:36 -04:00
Dale Wijnand 8f4b8abb7b
Run scalafmt & test:scalafmt 2018-04-24 16:12:10 +01:00
Dale Wijnand 82c39ec96f
Fix a "discarded non-Unit value" warning in TaskRunnerFork 2018-03-06 11:54:13 +00:00
Dale Wijnand 87dfb2c0f5
Remove all warnings from stdTaskProj 2017-12-12 13:02:19 +00:00
Dale Wijnand 9f1d60be60
Rewrite to polymorphic function syntax 2017-10-25 10:23:46 +01:00
Dale Wijnand f662fdda8e
Rewrite to function syntax 2017-10-25 10:22:48 +01:00
Dale Wijnand 35c3542492
Get rid of Fn1 2017-10-25 10:21:00 +01:00
Simon Schäfer 93e08b7ee7 Fix warnings about unused pattern vars in various projects 2017-10-19 13:07:24 +02:00
Dale Wijnand a41727fb17
Add, configure & enforce file headers 2017-10-05 09:03:40 +01:00
Dale Wijnand 805b76f3d4
Add back, re-configure & re-enable Scalafmt 2017-08-10 16:35:23 +01:00
Eugene Yokota da046791e0 Apply Scalafmt formatting 2017-04-21 04:48:31 -04:00
Eugene Yokota 9e02995ac0 Bump to Zinc 1.0.0-X14 2017-04-18 00:56:22 -04:00
Dale Wijnand c9ba9502a7
Work-around actions/depends-on failure 2017-04-04 13:41:11 +01:00
Dale Wijnand 7cd285f1b0
Copy all attributes for all methods in SingleInTask
For when := is used over <<= for 'triggeredBy', 'runBefore', etc..
2017-04-03 17:34:17 +01:00
Dale Wijnand 570ef0a379
Fix runBefore with := 2017-04-03 17:34:16 +01:00
Dale Wijnand 88ded6cb21
Fix triggeredBy with :=
Fixes #1444
2017-04-03 17:34:15 +01:00
Eugene Yokota 180bdfd129 Bump underlying modules to latest 2017-03-23 12:41:24 -04:00
Dale Wijnand e67cd6948b
Fix a bunch but not all compile warnings 2017-03-03 01:33:44 +01:00
Josh Soref 1ee0e5dd0b spelling: computation 2017-01-20 08:11:45 +00:00
Dale Wijnand 7fcfec8b8e
-sbinary/+sjson-new, -datatype/+contraband & upgrades
* start to replace sbinary with sjson-new
* upgrade from sbt/datatype to sbt/contraband
* upgrade and migrate to new sbt modules APIs
2017-01-05 21:59:00 +00:00
Dale Wijnand 43821667bf
Upgrade scalariform version 2016-12-11 12:13:11 +00:00
kenji yoshida 27fe8eb6f7 remove unused imports (#2719) 2016-08-30 07:29:17 +01:00
Dale Wijnand deea82542c Remove unused imports 2016-07-12 11:55:10 +01:00
Dale Wijnand 4c75d778b9 Group imports 2016-07-07 18:21:25 +01:00
Dale Wijnand 32760bed55 Remove some fatal exception catching 2016-07-07 18:21:25 +01:00
Dale Wijnand 168d3aa267 Cleanup stdTaskProj 2016-06-21 08:09:30 +01:00
Eugene Yokota ee272d780e Reorganize directory structure 2016-05-06 16:01:49 -04:00