Skip to content

Commit 4d07285

Browse files
committed
Merge branch 'master' into fork/an-tex/master
2 parents f06f39d + 29e14f9 commit 4d07285

File tree

18 files changed

+278
-89
lines changed

18 files changed

+278
-89
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,16 @@ jobs:
1313

1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v2
16+
uses: actions/checkout@v4
1717

1818
- name: Set up JDK 1.8
19-
uses: actions/setup-java@v1
19+
uses: actions/setup-java@v4
2020
with:
21-
java-version: 1.8
21+
distribution: temurin
22+
java-version: 8
23+
cache: sbt
2224

23-
- name: Cache SBT
24-
uses: actions/cache@v2
25-
with:
26-
path: |
27-
~/.ivy2/cache
28-
~/.sbt
29-
key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt', '**/plugins.sbt') }}
25+
- uses: sbt/setup-sbt@v1
3026

3127
- name: Run tests
3228
run: sbt test mdoc

.github/workflows/release.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Release
2+
on:
3+
push:
4+
branches: [master, main]
5+
tags: ["*"]
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
with:
12+
fetch-depth: 0
13+
- uses: actions/setup-java@v4
14+
with:
15+
distribution: temurin
16+
java-version: 8
17+
cache: sbt
18+
- uses: sbt/setup-sbt@v1
19+
- run: sbt ci-release
20+
env:
21+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
22+
PGP_SECRET: ${{ secrets.PGP_SECRET }}
23+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
24+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
target/
22
.bsp/
3+
.bloop/
4+
.idea/
5+
.metals/
6+
.vscode/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Usage
1616

1717
Add the library as "provided", because it's only needed during compilation and not at runtime:
1818
```sbt
19-
libraryDependencies += "com.github.dwickern" %% "scala-nameof" % "3.0.0" % "provided"
19+
libraryDependencies += "com.github.dwickern" %% "scala-nameof" % "4.0.0" % "provided"
2020
```
2121

2222
And import the package:

build.sbt

Lines changed: 27 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
import ReleaseTransformations._
2-
31
ThisBuild / organization := "com.github.dwickern"
42

5-
lazy val scala213 = "2.13.4"
6-
lazy val scala212 = "2.12.13"
7-
lazy val scala211 = "2.11.12"
3+
lazy val scala3 = "3.3.5"
4+
lazy val scala213 = "2.13.16"
5+
lazy val scala212 = "2.12.20"
86

97
lazy val root = project.in(file("."))
108
.aggregate(nameof.projectRefs: _*)
119
.enablePlugins(MdocPlugin)
1210
.settings(
1311
// for IntelliJ import: pick one project from the matrix to use
14-
nameof.jvm(scala213).settings,
12+
nameof.jvm(scala3).settings,
1513
target := baseDirectory.value / "target",
1614
ideSkipProject := false,
1715
publish / skip := true,
@@ -21,53 +19,34 @@ lazy val root = project.in(file("."))
2119
lazy val nameof = (projectMatrix in file("."))
2220
.settings(
2321
name := "scala-nameof",
24-
publishTo := sonatypePublishToBundle.value,
25-
releaseCrossBuild := true,
2622
ideSkipProject := true,
2723
libraryDependencies ++= Seq(
28-
"org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided",
29-
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided",
30-
"org.scalatest" %%% "scalatest" % "3.2.3" % Test,
31-
"com.chuusai" %% "shapeless" % "2.3.3" % Test,
24+
"org.scalatest" %% "scalatest" % "3.2.19" % Test,
25+
"javax.annotation" % "javax.annotation-api" % "1.3.2" % Test,
3226
),
3327
)
34-
.jsPlatform(scalaVersions = Seq(scala213, scala212, scala211))
35-
.jvmPlatform(scalaVersions = Seq(scala213, scala212, scala211))
28+
.jvmPlatform(scalaVersions = Seq(scala3), Seq(
29+
libraryDependencies ++= Seq(
30+
"org.typelevel" %% "shapeless3-test" % "3.4.3" % Test,
31+
)
32+
))
33+
.jvmPlatform(scalaVersions = Seq(scala213, scala212), Seq(
34+
libraryDependencies ++= Seq(
35+
"org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided,
36+
"org.scala-lang" % "scala-compiler" % scalaVersion.value % Provided,
37+
"com.chuusai" %% "shapeless" % "2.3.12" % Test,
38+
),
39+
))
3640

3741
Global / excludeLintKeys += ideSkipProject
3842

39-
ThisBuild / pomExtra := {
40-
<url>https://github.com/dwickern/scala-nameof</url>
41-
<licenses>
42-
<license>
43-
<name>MIT license</name>
44-
<url>http://www.opensource.org/licenses/mit-license.php</url>
45-
</license>
46-
</licenses>
47-
<scm>
48-
<connection>scm:git:github.com/dwickern/scala-nameof.git</connection>
49-
<developerConnection>scm:git:git@github.com:dwickern/scala-nameof.git</developerConnection>
50-
<url>github.com/dwickern/scala-nameof.git</url>
51-
</scm>
52-
<developers>
53-
<developer>
54-
<id>dwickern</id>
55-
<name>Derek Wickern</name>
56-
<url>https://github.com/dwickern</url>
57-
</developer>
58-
</developers>
59-
}
60-
61-
releaseProcess := Seq[ReleaseStep](
62-
checkSnapshotDependencies,
63-
inquireVersions,
64-
runClean,
65-
runTest,
66-
setReleaseVersion,
67-
commitReleaseVersion,
68-
tagRelease,
69-
releaseStepCommandAndRemaining("+publishSigned"),
70-
releaseStepCommand("sonatypeBundleRelease"),
71-
setNextVersion,
72-
commitNextVersion,
43+
ThisBuild / homepage := Some(url("https://github.com/dwickern/scala-nameof"))
44+
ThisBuild / licenses := Seq(License.MIT)
45+
ThisBuild / developers := List(
46+
Developer(
47+
id = "dwickern",
48+
name = "Derek Wickern",
49+
email = "dwickern@gmail.com",
50+
url = url("https://github.com/dwickern")
51+
)
7352
)

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version = 1.4.7
1+
sbt.version = 1.9.9

project/plugins.sbt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
logLevel := Level.Warn
22

3-
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.4.0")
4-
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.5")
5-
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.2")
6-
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13")
7-
addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.7.0")
8-
addSbtPlugin("org.jetbrains" % "sbt-ide-settings" % "1.1.0")
9-
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.17" )
3+
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.9.2")
4+
addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.10.0")
5+
addSbtPlugin("org.jetbrains.scala" % "sbt-ide-settings" % "1.1.2")
6+
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.6.4" )
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.github.dwickern.macros
2+
3+
import scala.quoted.*
4+
5+
trait NameOf {
6+
/**
7+
* Obtain an identifier name as a constant string.
8+
*
9+
* Example usage:
10+
* {{{
11+
* val amount = 5
12+
* nameOf(amount) => "amount"
13+
* }}}
14+
*/
15+
transparent inline def nameOf(inline expr: Any): String = ${NameOfImpl.nameOf('expr)}
16+
17+
/**
18+
* Obtain an identifier name as a constant string.
19+
*
20+
* This overload can be used to access an instance method without having an instance of the type.
21+
*
22+
* Example usage:
23+
* {{{
24+
* class Person(val name: String)
25+
* nameOf[Person](_.name) => "name"
26+
* }}}
27+
*/
28+
transparent inline def nameOf[T](inline expr: T => Any): String = ${NameOfImpl.nameOf('expr)}
29+
30+
/**
31+
* Obtain a type's unqualified name as a constant string.
32+
*
33+
* Example usage:
34+
* {{{
35+
* nameOfType[String] => "String"
36+
* nameOfType[fully.qualified.ClassName] => "ClassName"
37+
* }}}
38+
*/
39+
transparent inline def nameOfType[T]: String = ${NameOfImpl.nameOfType[T]}
40+
41+
/**
42+
* Obtain a type's qualified name as a constant string.
43+
*
44+
* Example usage:
45+
* {{{
46+
* nameOfType[String] => "java.lang.String"
47+
* nameOfType[fully.qualified.ClassName] => "fully.qualified.ClassName"
48+
* }}}
49+
*/
50+
transparent inline def qualifiedNameOfType[T]: String = ${NameOfImpl.qualifiedNameOfType[T]}
51+
}
52+
object NameOf extends NameOf

0 commit comments

Comments
 (0)