Comments (4)
About final vals - #158
Thanks for the pointer. And it seems to do the trick also for annotation parameters.
As for the import, I also don't see why it'd be necessary unless someone disables the default imports.
I had a discussion about this issue on Discord and it seems the import is there for exactly for that reason: if somene uses Yno-imports
or -Yno-predef
. See commit e924a28
I am not sure why someone would do that and if we need to keep the import then the plugin will need to generate Scala 2/3 specific code.
from sbt-buildinfo.
I ran into this too. Here's my workaround:
// put this in project directory and use with:
// buildInfoRenderFactory := sbtbuildinfo.Scala3CaseObjectRenderer.apply
package sbtbuildinfo // couldn't access ScalaCaseObjectRenderer outside this pkg (?)
final case class Scala3CaseObjectRenderer(
options: Seq[BuildInfoOption],
pkg: String,
obj: String)
extends ScalaRenderer {
private lazy val delegate = ScalaCaseObjectRenderer(options, pkg, obj)
def extension: String = delegate.extension
def fileType: BuildInfoType = delegate.fileType
def renderKeys(infoKeysNameAndValues: Seq[BuildInfoResult]): Seq[String] =
delegate.renderKeys(infoKeysNameAndValues).map {
case "import scala.Predef._" => "import scala.Predef.*"
case x => x
}
}
from sbt-buildinfo.
@kubukoz and @eed3si9n, is that import of scala.Predef._
even necessary at all?
Removing it, the code still compiles with Scala 3, 2.12, 2.11, and 2.10.
(I haven't tried to compile with earlier Scala versions as it requires a JDK earlier then 1.8.)
So I would suggest getting rid of the import altogether and also (which is a different issue) change code generation so all val
s are final and without a type annotation as the val
s then can be used as constants in annotation parameters.
For example, instead of generating
val version: String = "1.5.0+2-44650e3c-SNAPSHOT"
we should generate this
final val version = "1.5.0+2-44650e3c-SNAPSHOT"
from sbt-buildinfo.
About final vals - #158
As for the import, I also don't see why it'd be necessary unless someone disables the default imports.
from sbt-buildinfo.
Related Issues (20)
- multiarg infix syntax looks like a tuple and will be deprecated HOT 5
- Avoid the use of Symbol literal
- BuildInfo is not generated using sbt 1.3.13 HOT 3
- migrate to GitHub Actions from Travis CI HOT 2
- Inifinite re-compilation when BuildInfoOption.BuildTime is used inside metals + sbt bsp
- Please migrate from bintray for release HOT 3
- BuildInfoOption.BuildTime causes empty scoverage reports
- Travis CI dropped HOT 2
- Unescaped value breaks comments HOT 1
- Also support the test configuration HOT 3
- Backslash escaping is broken
- Migrate to `com.github.sbt`?
- Support Sets
- feature request: add @generated HOT 2
- Scala 3 compatibility broken for ToJson HOT 2
- Scala 2.13.x support HOT 3
- Not able to download version `0.10.0` from public infrastructure HOT 6
- 0.11.0 missing from scala.jfrog.io HOT 1
- PlayFramework using sbt-buildinfo cause an error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sbt-buildinfo.