tindzk / seed

Build tool for Scala projects
https://tindzk.github.io/seed/
Apache License 2.0
238 stars 13 forks source link

Implement publishing to Bintray #77

Closed tindzk closed 4 years ago

tindzk commented 4 years ago

This introduces two user-facing features: the ability to publish and document modules. The changes resulted in the stabilisation of the artefact resolution and progress bar logic. Furthermore, the import keyword is now available in the global Seed configuration file.

With the new CLI command publish, modules can be published to a repository. It builds, packages and uploads the specified modules. At the moment, only Maven-style Bintray repositories are supported. For each supplied module, JAR artefacts along with a POM file are created. These artefacts contain the compiled classes, source files and documentation. Publishing of sources and documentation is optional and can be disabled. Progress bars are shown when publishing modules. Unless specified, Seed will attempt to read the version from the project's Git repository. Internally, the feature uses the Apache HTTP client, wrapped as a ZIO task, and sends requests to the Bintray REST API.

The newly-introduced CLI command doc runs Scaladoc on the supplied modules and generates an HTML documentation for them. Seed runs the Scala compiler directly, bypassing Bloop. This results in an additional compilation pass. Compiler bridges are provided for Scala 2.11, 2.12 and 2.13. However, the actual resolution of the scala-compiler artefact occurs during runtime. Therefore, documentation generation is compatible with alternative compilers such as Typelevel Scala.

The aforementioned features required changes to the artefact resolution. Previously, all dependencies were resolved at once. However, modular projects are likely to contain libraries with diverging versions. A resolution pass in Coursier merges these duplicate libraries, only retaining the latest version. This may lead to unexpected compile- and runtime behaviour. The new resolution logic solves this limitation by performing a separate resolution pass for each module. Test modules are resolved separately too. As a consequence of these changes, the resolution is slightly slower, but still acceptable on larger projects.

A further change is that the standard library's organisation and version are forcibly set during dependency resolution by using Coursier's ResolutionParams feature. This avoids having to patch artefacts later on, e.g. during generation.

The progress bar logic was refactored and several bugs were fixed. Notably, as build targets may run asynchronously, they can produce output while the project is still compiling. In this case, the progress bar output would get corrupted. The graphical glitch was resolved by using the console output's logger in seed.cli.BuildTarget.buildTargets().

Finally, the import keyword, previously only available in build files, can now be used within the global Seed configuration. Since Bintray repository credentials are part of this file, users may want to move the credentials to a custom file and import it instead.