scala-steward icon indicating copy to clipboard operation
scala-steward copied to clipboard

Support extracting dependencies from a YAML/JSON file

Open pshirshov opened this issue 6 years ago • 10 comments

Hi,

We are using Steward for a while and it's very convenient. Though recently we started generating sbt projects (there are some things which are very hard to squeeze into plain sbt) and we don't want to keep them in the repository.

Would it be possible to implement a feature allowing us to keep all our dependencies in a YAML/JSON file in the root of our repository? So both Steward and our project generator may parse it.

pshirshov avatar Sep 11 '19 15:09 pshirshov

The project in question: https://github.com/7mind/izumi, build.sbt is now generated by sbtgen script

neko-kai avatar Sep 13 '19 21:09 neko-kai

If you want Scala Steward to update version numbers of your dependencies, you need to have a sbt project which depend on these dependencies. So if your script contains the same dependencies as defined in the sbt build, Scala Steward could then change both version numbers.

I'm doing something similar to keep Giter8 templates up-to-date and it could also be used to update Ammonite's ivy-imports.

fthomas avatar Sep 14 '19 20:09 fthomas

If you want Scala Steward to update version numbers of your dependencies, you need to have a sbt project which depend on these dependencies.

I understand that, but it's very inconvenient as per I'm generating projects and there are many possible form of one project (different artifacts, different dependencies, etc)

Maybe it's possible to support declarative dependency data source, like a yaml file .scala-steward.yml in the root of the repository?

pshirshov avatar Sep 14 '19 20:09 pshirshov

Scala Steward already support repository specific configuration in .scala-steward.conf. https://github.com/fthomas/scala-steward/blob/master/docs/repo-specific-configuration.md

exoego avatar Sep 14 '19 20:09 exoego

Maybe it's possible to extend that config with another section, like

dependencies {
  better_files = "com.github.pathikrit%%better-files%3.8.0"
}

?

pshirshov avatar Sep 14 '19 20:09 pshirshov

And it might also requires a new entry to configure which files should be updated, something like this:

additionalFilesToUpdate = [
  { path : "path/to/a/file.ext" },
  { pattern : ".md" }
]

exoego avatar Sep 14 '19 21:09 exoego

In fact in my case it would be enough to have .scala-steward.conf itself updated. My project generator may parse it and take dependencies from there.

pshirshov avatar Sep 14 '19 21:09 pshirshov

@pshirshov @neko-kai Now that https://github.com/7mind/izumi/issues/672 is closed, can this issue be closed, too?

fthomas avatar Oct 17 '19 19:10 fthomas

We made a dirty workaround for our problems. But it would be really great if you may implement a feature like I described.

pshirshov avatar Oct 17 '19 21:10 pshirshov

Maybe it's possible to support declarative dependency data source, like a yaml file .scala-steward.yml in the root of the repository?

This reminds me of @alexarchambault's deps which centralizes all dependencies and resolvers in a single deps.json which then can be used in sbt or Mill builds as source for dependencies. Since this issue has been opened, Scala Steward started supporting multiple build tools (sbt, Maven, and Mill). Supporting a build tool means extracting dependencies and resolvers from the build. The deps.json provides exactly that so it is not far fetched to use that as source for dependencies and resolvers and handle it like any other build tool in Scala Steward. The only thing required to support deps.json would be an implementation of the BuildToolAlg interface.

fthomas avatar Nov 11 '20 19:11 fthomas