forked from scalacenter/scaladex
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor ScalaTargetType/ScalaTarget
The refactor in this commit is driven by the work in the subsequent commit for issue scalacenter#659 (creating a Scaladex badge that supplies concise info on supported Scala versions). The key word there is 'concise' - given the many Scala artifacts that can be published for a single artifact version (the matrix of Scala language version, the platform - Scala JS/Native/SBT - and the platform version), achieving a concise summary requires a lot of grouping. Grouping by Scala `LanguageVersion` was easy enough, but grouping by platform & platform version was harder, as there wasn't any existing class to represent that. Consequently, I introduced the concept of a 'platform edition' (eg 'Scala JS 0.6', or 'Scala Native 0.4'), which is composed of two values: * targetType (Scala JS, Scala Native, or SBT) * platform version (eg the version '0.6' or '1.0' of Scala JS) ...this is like a `ScalaTarget`, but without the Scala Language version that `ScalaTarget` includes (eg a `ScalaTarget` is specifically compiled for, eg, _Scala 2.11_ on Scala JS 0.6). Having introduced the concept of `PlatformEdition`, it made sense to redefine relevant `ScalaTarget`s in terms of that - to do this meant moving several ad-hoc methods from the companion objects of `ScalaTarget` implementations (ie `ScalaJs`, `ScalaNative`, `SbtPlugin`) to the corresponding `ScalaTargetType` implementations and making them more widely available, by declaring them in the `PlatformVersionedTargetType`. This removed duplication of this code: * producing a String `render` value for platform names * checking validity of platform versions. A lot of repetition was removed, and in fact most of the `ScalaTarget` companion objects were now empty and could be deleted. Another smaller change was prompted by the upcoming need to identify a `ScalaTargetType` by name (when the user specifies it as a query string parameter). To do that, you need a full list of `ScalaTargetType`s, and then you can also use that list to create an `Ordering[ScalaTargetType]` Also tidied up various tests that were creating their own platform version constants (as I was already moving equivalent constants from `ScalaTarget` companion objects to `ScalaTargetType` objects)
- Loading branch information
Showing
7 changed files
with
141 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.