Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More complex builds for github:org/repo rewrites #280

Closed
olafurpg opened this issue Aug 10, 2017 · 4 comments
Closed

More complex builds for github:org/repo rewrites #280

olafurpg opened this issue Aug 10, 2017 · 4 comments

Comments

@olafurpg
Copy link
Contributor

olafurpg commented Aug 10, 2017

Currently, github:org/repo rewrites need to fit in a single file. It would be nice if scalafix supported more complex builds to accommodate

  • multiple files
  • dependencies
  • custom scalac options?
  • generated sources (e.g., BuildInfo)

There are several ways to achieve this

  • add scalafix/build.conf file that includes the build definition (files, dependencies, options). This would mean pretty much re-implementing a build tool.
  • invoke sbt programmatically to builds the scalafix/rewrites projects from source. sbt rewrites/fullClasspath will give the classpath and scalafix won't have to compile sources itself.

I'm personally leaning towards the second option. I don't have much experience with using sbt programmatically or with sbt source dependencies but if it works then it's a very powerful solution. Also, this solution would give incremental and cached compilation.

@gabro
Copy link
Collaborator

gabro commented Aug 10, 2017

Yeah, let's not implement our own build tool 👍

@olafurpg
Copy link
Contributor Author

olafurpg commented Sep 12, 2017

After more thinking, here is what I think strikes a nice balance between supporting more complex builds without reinventing the wheel

  • github:org/repo clones org/repo with jgit
  • compiles all .scala sources in the scalafix/rules directory (and scalafix/rewrites for compat with <0.5 directories)
  • classload all rules in compiled sources, if there is a /v1 suffix, classload all rules in package rule.v1 package

This scheme scales nicely for both migration rewrites with a /v1 suffix and non-migration rules such as olafurpg/FinalCaseClass, which don't have a /v1 suffix.

This allows rules like typelevel/cats/v1 to become more complex without requiring a publish step to maven.

This approach will also scale nicely for non-GitHub projects, since it's based on git.

@olafurpg olafurpg added this to the v0.5.1 milestone Sep 12, 2017
@gabro
Copy link
Collaborator

gabro commented Sep 12, 2017

github:org/repo clones org/repo with jgit

👍 I would clone it with --depth=1

@olafurpg olafurpg removed this from the v0.5.4 milestone Nov 13, 2017
@olafurpg
Copy link
Contributor Author

I suggest that we close this ticket with "Please publish your rule to maven central". Published rules have the same UX as built-in scalafix rules. Rules that want to enjoy the benefits of being compileable from source will need to meet the criteria

  • no dependencies
  • single file

bjaglin pushed a commit to liancheng/scalafix that referenced this issue May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants