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

Towards a Scala Native 0.5.0 release #369

Merged
merged 7 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 17 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@
![CI](/~https://github.com/ekrich/sconfig/workflows/CI/badge.svg)
[![Scala.js](https://www.scala-js.org/assets/badges/scalajs-1.0.0.svg)](https://www.scala-js.org)

Configuration library written in [Scala](https://www.scala-lang.org/) which is a direct translation
of the original widely used Java library.
Configuration library written in [Scala](https://www.scala-lang.org/) which is a direct translation of the original widely used Java library.

[Scala JVM](https://www.scala-lang.org/), [Scala Native](https://scala-native.readthedocs.io/), and [Scala.js](https://www.scala-js.org/)
are supported. Scala JVM is fully supported whereas the other platforms support a subset of the full API.

For motivation and background about this project see the [PR](/~https://github.com/lightbend/config/pull/600)
to the original project. The TLDR is the library was ported to Scala to support Scala Native so
[scalafmt](https://scalameta.org/scalafmt/) which uses HOCON configuration could be compiled into
a native application.
For motivation and background about this project see the [PR](/~https://github.com/lightbend/config/pull/600) to the original project. The TLDR is the library was ported to Scala to support Scala Native so [scalafmt](https://scalameta.org/scalafmt/) which uses HOCON configuration could be compiled into a native application.

Care has been taken to keep the API the same but changes were needed when moving from the Java API.
Using Java is also possible as demonstrated by including the working Java examples.
Care has been taken to keep the API the same but changes were needed when moving from the Java API. Using Java is also possible as demonstrated by including the working Java examples.

If you are looking for the original Java API, see
[/~https://github.com/lightbend/config](/~https://github.com/lightbend/config).
Expand All @@ -38,26 +33,24 @@ All available versions can be seen at the [Maven Repository](https://mvnreposito
## Cross Build Versions
[![Scala.js](https://www.scala-js.org/assets/badges/scalajs-1.0.0.svg)](https://www.scala-js.org)

| Scala Version | JVM | Scala.js (1.x) | Native (0.4.x) |
| Scala Version | JVM | Scala.js (1.x) | Native (0.5.x) |
| ---------------------- | :-: | :-------------------: | :------------: |
| 2.12.x | ✅ | ✅ | ✅ |
| 2.13.x | ✅ | ✅ | ✅ |
| 3.x.x | ✅ | ✅ | ✅ |

Note: Scala 3 support on Scala Native 0.4.3-RC2 or greater. Scala 2.11 support through version 1.4.9.
* Scala Native 0.5.x support from 0.7.0.
* Scala 3 support on Scala Native 0.4.3-RC2 or greater.
* Scala 2.11 support through version 1.4.9.

## Usage and Help
[![Scaladoc](https://www.javadoc.io/badge/org.ekrich/sconfig_2.13.svg?label=scaladoc)](https://www.javadoc.io/doc/org.ekrich/sconfig_2.13)
[![scaladoc](https://javadoc.io/badge/org.ekrich/sconfig_3.svg?label=scaladoc3)](https://javadoc.io/doc/org.ekrich/sconfig_3)
[![Discord](https://img.shields.io/discord/633356833498595365.svg?label=&logo=discord&logoColor=ffffff&color=404244&labelColor=6A7EC2)](https://discord.gg/XSj6hQs)


Please refer to the original library documentation [here](/~https://github.com/lightbend/config).
This is to reduce the maintenance burden of this library.
Please refer to the original library documentation [here](/~https://github.com/lightbend/config). This is to reduce the maintenance burden of this library.

The intent is to keep the library in sync with the original but each PR needs to be be ported
to maintain feature parity. The documentation could contain features that are not yet implemented
in this library.
The intent is to keep the library in sync with the original but each PR needs to be be ported to maintain feature parity. The documentation could contain features that are not yet implemented in this library.

For specific changes, refer to the releases below.

Expand All @@ -66,44 +59,34 @@ For specific changes, refer to the releases below.
[![sconfig Scala version support](https://index.scala-lang.org/ekrich/sconfig/sconfig/latest.svg)](https://index.scala-lang.org/ekrich/sconfig/sconfig)
[![Latest scalafix version](https://index.scala-lang.org/scalacenter/scalafix/scalafix-core/latest.svg)](https://index.scala-lang.org/scalacenter/scalafix/scalafix-core)

This project publishes a [scalafix](https://scalacenter.github.io/scalafix/) rule to migrate
existing Scala 2 source code that uses `com.typesafe.config.Config` to this implementation.
Scalafix rules modify in place existing valid Scala code. Think of it as a fancy find-and-replace
tool that is aware of the Scala type system and can therefore narrowly tailor the changes
being made. (Since scalafix changes the source code on your file system, it's best to commit
any changes prior to running the rule, in case something weird happens.)
This project publishes a [scalafix](https://scalacenter.github.io/scalafix/) rule to migrate existing Scala 2 source code that uses `com.typesafe.config.Config` to this implementation. Scalafix rules modify in place existing valid Scala code. Think of it as a fancy find-and-replace tool that is aware of the Scala type system and can therefore narrowly tailor the changes being made. (Since scalafix changes the source code on your file system, it's best to commit any changes prior to running the rule, in case something weird happens.)

The rule will replace `com.typesafe.config` package references with `org.ekrich.config`,
and remove trailing parens on some methods (where the API changed from the Java implementation).
The rule will replace `com.typesafe.config` package references with `org.ekrich.config`, and remove trailing parens on some methods (where the API changed from the Java implementation).

Complete setup documentation and the current `scalafix` version can be found in the
[scalafix user guide](https://scalacenter.github.io/scalafix/docs/users/installation.html).
At a high level, the process is as follows:
Complete setup documentation and the current `scalafix` version can be found in the [scalafix user guide](https://scalacenter.github.io/scalafix/docs/users/installation.html). At a high level, the process is as follows:

1. Add scalafix to the project's `project/plugins.sbt` file using the version found above:

```scala
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "a.b.c")
```

2. Add this project to the project's `libraryDependencies`, but don't remove the old one yet!

(The old dependency needs to stay on the classpath until after the rule runs, because the
code must compile before it will run.)
(The old dependency needs to stay on the classpath until after the rule runs, because the code must compile before it will run.)

3. Run the scalafix sbt command shown below to apply the rule using the version of `sconfig`
selected. Replace the `x.y.z` below with the version (must be greater than version `1.4.5`
when scalafix was added):
3. Run the scalafix sbt command shown below to apply the rule using the version of `sconfig` selected. Replace the `x.y.z` below with the version (must be greater than version `1.4.5` when scalafix was added):

```
scalafixEnable; scalafixAll dependency:ReplaceTypesafeConfig@org.ekrich:sconfig-scalafix:x.y.x
```

4. Remove the old config dependency from the project's `libraryDependencies`
5. Commit the changes

## Versions

Release [1.7.0](/~https://github.com/ekrich/sconfig/releases/tag/v1.7.0) - (2023-04-16)<br/>
Release [1.6.0](/~https://github.com/ekrich/sconfig/releases/tag/v1.6.0) - (2023-12-28)<br/>
Release [1.5.1](/~https://github.com/ekrich/sconfig/releases/tag/v1.5.1) - (2023-09-15)<br/>
Release [1.5.0](/~https://github.com/ekrich/sconfig/releases/tag/v1.5.0) - (2022-09-19)<br/>
Expand Down
13 changes: 6 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ val isScala3 = Def.setting {
}
}

val scala212 = "2.12.18"
val scala213 = "2.13.12"
val scala3 = "3.3.1"
val scala212 = "2.12.19"
val scala213 = "2.13.13"
val scala3 = "3.3.3"

val javaTime = "1.1.9"
val scCompat = "2.11.0"
val javaTime = "1.3.0"
val scCompat = "2.12.0"

val versionsBase = Seq(scala212, scala213)
val versions = versionsBase :+ scala3
Expand Down Expand Up @@ -158,8 +158,7 @@ lazy val sconfig = crossProject(JVMPlatform, NativePlatform, JSPlatform)
.nativeSettings(
crossScalaVersions := versions,
nativeConfig ~= (
_.withLinkStubs(true)
.withEmbedResources(true)
_.withEmbedResources(true)
),
logLevel := Level.Info, // Info or Debug
libraryDependencies += "org.ekrich" %%% "sjavatime" % javaTime % "provided"
Expand Down
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ resolvers ++= Resolver.sonatypeOssRepos("snapshots")
// versions
val crossVer = "1.3.2"
val scalaJSVersion = "1.16.0"
val scalaNativeVersion = "0.4.17"
val scalafix = "0.11.1"
val scalaNativeVersion = "0.5.1"
val scalafix = "0.12.0"

// includes sbt-dynver sbt-pgp sbt-sonatype sbt-git
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
Expand Down
16 changes: 16 additions & 0 deletions sconfig/native/src/main/scala/java/net/URLConnection.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package java.net

import scalanative.annotation.stub

class URLConnection {
@stub
def getLastModified(): scala.Long = ???
@stub
def connect(): Unit = ???
@stub
def getContentType(): String = ???
@stub
def getInputStream(): java.io.InputStream = ???
@stub
def setRequestProperty(key: String, value: String): Unit = ???
}