Commit Graph

151 Commits

Author SHA1 Message Date
Eugene Yokota fd7cec0148 use okhttp to download the artifacts
This adds a custom URLHandler that internally uses Square OkHttp.

Fixes sbt/librarymanagement#95
2017-05-26 04:13:55 -04:00
Eugene Yokota dd4b33105b add Gigahorse 2017-05-15 16:34:38 -04:00
eugene yokota 9e799a80f3 Merge pull request #97 from scalacenter/unique-resolvers
Allow to define concrete resolvers for dependencies
2017-05-12 22:57:53 -04:00
jvican 8bb1676e61
Allow to define concrete resolvers for dependencies
Sometimes, for predictability and performance, we may be interested in
specifying the concrete resolver that a `ModuleID` should use.

This patch achieves this by adding a new field to `UpdateOptions` and
then getting this information from the `SbtChainResolver`, that will
select the concrete resolver for a given dependency descriptor.

Why is this useful? Well, two reasons:

* Predictable behaviour. We have the guarantee that an artifact only
  comes from a concrete resolver.
* Resolution speedup. Around 1/3 or 1/2 times faster than normal
  resolution in a moderate test case scenario. If there is a lot of
  latency or network connection is poor, speedups will be higher.

LOGS:

```
NORMAL RESOLUTION TIME 1790
FASTER RESOLUTION TIME 1054
```

```
NORMAL RESOLUTION TIME 2078
FASTER RESOLUTION TIME 1055
```

Lots of projects can benefit from this option, as well as organizations
and companies. This will eventually integrate with the dependency lock
file, but can be used independently of it.
2017-05-12 23:47:05 +02:00
jvican 92cc5339eb
Fix sbt/sbt#2650: Degrade log level and clarify
To ensure that SNAPSHOTs are always the latest, we go through all the
resolved modules and check their timestamps. Good.

However, if in the process of reparsing/redownloading the module
descriptor we fail (or it's not found in that resolver at all), then we
cannot refresh the resolved module that could have been internalized or
heavily cached in memory by ivy. We do this for correctness.

This patch does two things:

1. Adds more comments.
2. Warns only when there are parsing errors in ivy files.
3. Adds debug info in the rest of the cases.

This removes the pain of seeing `Unable to parse` that could be caused by
other reasons that are not related to parsing at all and which would not
affect the algorithm at hand. For instance, if we get a URLResource,
that's totally fine -- there is no way we could parse the ivy file. Ivy
uses URLResources in several cases where the artifact origin URL is
specified.
2017-05-12 18:56:00 +02:00
eugene yokota ccc63d3ee0 Merge pull request #100 from scalacenter/add-frozen-mode
Add a frozen mode to update configuration
2017-05-12 12:43:24 -04:00
eugene yokota 40fa6dcd3b Merge pull request #96 from scalacenter/sbt-chain-resolver-rewrite
Make `SbtChainResolver` readable
2017-05-12 12:40:26 -04:00
jvican b1e36e50c8
Add review comments and improve docs 2017-05-11 18:10:01 +02:00
jvican 5ff32f2a99
Add a frozen mode to update configuration
The frozen mode is used by the dependency lock file.

It makes sure that the resolution is always intransitive and that ivy
does not check for changed dependencies and stores that information in
the resolved ivy files. Following the ivy documentation, the last change
may bring a slight performance improvement:

http://ant.apache.org/ivy/history/latest-milestone/use/resolve.html
2017-05-11 18:00:24 +02:00
jvican 7391290d8a
Add comments to `SbtChainResolver` implementation 2017-05-10 20:34:41 +02:00
jvican 57d5908737
Make `SbtChainResolver` readable
This is the most important part of the sbt ivy management and it's
almost unreadable in the previous shape...

This attempts to make a rewrite without any semantic change.
2017-05-10 20:27:53 +02:00
jvican 96c775c445
Remove previous custom offline implementation
The previous custom offline implementation was not working on 100% of
the cases and relied on the TTL of ivy. As the previous commit
enabled the native offline implementation provided by ivy as of 2.3.0,
this functionality is not useful anymore.

The current place to specify offline is `UpdateConfiguration`, and not
`InlineIvyConfiguration` that is required to instantiate sbt. With the
current approach, we can be online or offline without having to
instantiate ivy sbt twice.

I will provide a Scalafix rewrite for this change.
2017-05-09 11:02:34 +02:00
jvican 67d9012a17
Add offline mode to `UpdateConfiguration`
The following commit tries to address the well-known issue that sbt
cannot be used in offline mode. In order to enable that use case, this
commit adds support for a flag in update configuration called `offline`
that users can change as they wish (and that sbt will expose via
settings).

It adds tests to check that the resolution uses the caches instead of
trying to resolve from the Internet. Unfortunately, ivy does not expose
a way to know whether a resolution was made from the cache or the
Internet, so the test case invents a metric to check that resolution
indeed happens from cache.

In order to benefit from this 100%, we need to update to ivy 2.4.0 or
cherry-pick a commit because a major issue in `useCacheOnly` has been
fixed: https://issues.apache.org/jira/browse/IVY-1515.

In short, this is good for the dependency lock file too. Since we can
make sure that once we have downloaded and resolved all the dependencies
locally, we do resolve from the cache.
2017-05-09 11:02:34 +02:00
eugene yokota a3eb9fd1a2 Merge pull request #91 from scalacenter/clean-update
Deduplicate and remove deprecations in `IvyActions`
2017-05-02 12:19:03 -04:00
eugene yokota ec652130f0 Merge pull request #90 from scalacenter/add-parallel-ivy
Fix sbt/sbt#2982: Add a parallel Ivy engine
2017-05-02 12:13:49 -04:00
jvican 0885ae1a96
Add documentation to `updateEither` 2017-04-28 11:28:38 +02:00
jvican 429dd84393
Remove deprecated methods in `IvyActions` 2017-04-28 10:19:12 +02:00
jvican 1f4030ff17
Remove unused apply in `UnresolvedWarning` 2017-04-28 10:19:12 +02:00
jvican c84d297912
Turn `ResolveException` private[sbt]
Plus, remove deprecated method using `ResolveException`.
2017-04-28 10:19:12 +02:00
jvican 258cb7c5ac
Remove unused instance of `retrieve`
This commit removes the second instance of `retrieve` that was private
and unused, therefore reducing the API surface of `IvyActions`.
2017-04-28 10:19:12 +02:00
jvican eea500d64f
Remove coded uplication in `updateEither`
This commit reduces the code duplication in `updateEither` which was
duplicating a good deal of the resolution logic to deal with the
different resolution mechanisms: the simple one and the cached one.

It also unifies the signatures of the helpers that are invoked by
`updateEither`, removing the weirdness of the different return type
signatures and ad-hoc logic handling.
2017-04-28 10:19:11 +02:00
jvican b68498d013
Remove unused arguments in clean and use site
`cleanCachedResolutionCache` and `clean` were doing extra work because
`clean` does only need to clean the cache in the configuration (that is
a class parameter).
2017-04-28 10:19:06 +02:00
jvican 8c993d2d53
Fix sbt/sbt#2982: Add a parallel Ivy engine
This is a port of https://github.com/sbt/sbt/pull/2992.

Original description of the feature:

```
Ivy downloads have traditionally been single-threaded.

Parallel downloads are a must for a modern build tool. This commit
builds upon the work done by Josh Suereth in the branch
sbt/ivy-parallel-download-artifact.

To avoid adding external dependencies, it uses the Scala parallel
collections. If maintainers consider that is worth it to use a more
modern and appropriate approach, like Task, I'm happy to reimplement
the features with it.
```

This commit does not preserve Josh's metadata in the commit since the
whole design of the repository has changed and I did not know how to
import a commit from sbt/sbt. However, it does apply several changes to
the original PR.

Co-authored-by: Josh Suereth <joshua.suereth@gmail.com>
2017-04-27 00:02:37 +02:00
jvican e1d98a1ec2
Fix sbt/sbt#1518: Handle cross-versioned exclusions
The following PR does two things:

* Removes the unnecessary `SbtExclusionRule` that was introduced to
  exclude artifacts at the project level (and not the dependency level).
  This change was done in an independent class to avoid breaking
  bincompat in 0.13.x series.
* Handle exclusion rules correctly, propagating the cross version to the
  exclusions of the dependencies.

To fix sbt/sbt#1518, this PR takes the avenue taken in
`SbtExclusionRule`, it accepts `GroupArtifactID` which should be the
preferred way to specify dependencies from now on. Unlike
`SbtExclusionRule`, it also supports `ModuleID` for those that want to
exclude a concrete dependency.

`InclExcl` did not have any tests. The following commit also adds a
testing suite for it, showing how the issue it's fixed and how you
should use `exclude` if you're calling directly `ExclusionRule` instead
of passing in `GroupArtifactID` and `ModuleID`.
2017-04-26 23:44:14 +02:00
jvican d42ea869d0
Apply formatting 2017-04-26 22:55:38 +02:00
Eugene Yokota 4b0b3a05f9 Bump to util 1.0.0-M23
I'm now going to use `CacheStore.apply` in `JsonUtil` (used by cached resolution). This gets rid of `fileToStore` parameter from a bunch of classes and simplifies the setup around librarymanagement.
2017-04-17 13:29:02 -04:00
Dale Wijnand 40e34b3e8e
Make RichUpdateReport return Vectors & cuddle sys.error 2017-04-13 10:08:53 +01:00
Dale Wijnand 7f25614d71
Expose more in RichUpdateReport
Fixes #83
2017-04-13 09:28:00 +01:00
Dale Wijnand 80715dfb57
Make ScmInfo devConnection default to None 2017-04-05 15:51:36 +01:00
eugene yokota 6fe4d820ed Merge pull request #81 from eed3si9n/fport/3017
[fport] Fix version parsing
2017-04-04 17:50:58 -07:00
Eugene Yokota 36121bed74 Fix version parsing
Fixes sbt/sbt#3011
2017-04-04 18:34:37 -04:00
Eugene Yokota bb258f42a6 Maven version range improvement
Previously, when the dependency resolver (Ivy) encountered a Maven version range such as `[1.3.0,)`
it would go out to the Internet to find the latest version.
This would result to a surprising behavior where the eventual version keeps changing over time
*even when there's a version of the library that satisfies the range condition*.

This changes to some Maven version ranges would be replaced with its lower bound
so that when a satisfactory version is found in the dependency graph it will be used.
You can disable this behavior using the JVM flag `-Dsbt.modversionrange=false`.

Fixes #2954
Ref #2291 / #2953
2017-04-04 16:22:28 -04:00
Guillaume Martres 0561c12d19 Fix support for published dotty nightly builds
Dotty nightly builds are published to maven, so they end up in
configuration "default", not "compile". We still need to look into
"compile" when dotty is published locally.

You can test this using https://github.com/smarter/dotty-example-project
by updating the sbt version used in project/build.properties and by
replacing "0.1.1-SNAPSHOT" by a nightly version like
"0.1.1-20170109-be64643-NIGHTLY" in build.sbt
2017-04-04 14:01:42 -04:00
Guillaume Martres 45288b5f80 Avoid NullPointerException in sbt.ScalaOverrideTest 2017-04-04 13:18:46 -04:00
Guillaume Martres 9375c88a8b OverrideScalaMediator: fix bootstrapping a Scala compiler
Fixes #2867, #2896
2017-04-04 13:18:32 -04:00
Dale Wijnand 1afe7114e8
Expose RichUpdateReport enrichment 2017-04-03 12:39:52 +01:00
Dale Wijnand 723abc945f
Overload RichUpdateReport#select instead of using default args 2017-04-03 12:39:39 +01:00
Dale Wijnand cbdbf23127
Expose RichUpdateReport & DependencyFilter
Fixes #42
2017-04-03 12:39:39 +01:00
eugene yokota 9cf41bbf36 Merge pull request #77 from dwijnand/ssh-based-repo-apis
Recover lost ssh-based repo API
2017-03-31 10:20:48 -07:00
Dale Wijnand 084c94a93c
Recover lost ssh-based repo API
Recover APIs I accidentally removed in
f2efa10af1.
2017-03-31 15:02:16 +01:00
Dale Wijnand fb049d181b
Add prefix support to Binary/Full 2017-03-31 10:48:45 +01:00
Dale Wijnand 87e8d87811
Allow for some customization in CrossVersion results
The old way to customize CrossVersion results was a `String => String`
function called 'remapVersion', removed in
301ec787f2.

That was removed because it's not possible to serialise Function1s, and
we want to serialise CrossVersion (and therefore ModuleID, etc) to be
able to transfer them in sbt server.

This commit reintroduces a less-powerful way to vary the results of
apply CrossVersion, but just providing the opportunity to define a
suffix. From looking at the users of CrossVersion (Scala.js'
sbt-scalajs-plugin & Scala Native's sbt-crossproject) this looks to be
sufficient.
2017-03-31 10:24:16 +01:00
Dale Wijnand 92cc7c4cb1
Remove some compile warnings 2017-03-31 10:19:47 +01:00
Dale Wijnand ed6b57ff38 Merge pull request #51 from jroper/resolving-debug
Log resolving messages at debug level
2017-03-10 13:48:32 +00:00
Eugene Yokota c793c33740 fix test 2017-02-15 23:41:23 -05:00
Eugene Yokota caecbbabe7 util 1.0.0-M19 2017-02-15 23:12:01 -05:00
Eugene Yokota 27397de8cf Adjust to upstream 2017-01-15 22:54:15 -05:00
Eugene Yokota 95a209b033 Apply binary version conflict check to Compile related configs
Fixes #1466 Ref #2786

Even after fixing the mediator issue, we still have spurious binary
version conflict warning that does not account for sandbox
configurations.

This change follows the scalaVersionConfigs work.
2017-01-15 20:55:02 -05:00
Eugene Yokota c12c9c6187 Apply scalaVersion enforcement to Compile related configs
Fixes #2786. Ref #2634.

sbt 0.13.12 added Ivy mediator that enforces scalaOrganization and
scalaVersion for Scala toolchain artifacts.
This turns out to be a bit too aggressive because Ivy configurations
can be used as an independent dependency graph that does not rely on
the scalaVersion used by Compile configuration. By enforcing
scalaVersion in those graph causes runtime failure.

This change checks if the configuration extends Default, Compile,
Provided, or Optional before enforcing scalaVersion.
2017-01-15 20:52:58 -05:00
eugene yokota c3f5805574 Merge pull request #72 from sbt/fport/2757
[fport] CrossVersion.patch
2017-01-15 20:51:21 -05:00