README.md 4.9 KB
Newer Older
1
<img align="right" width="20%" height="30%" src="img.png" alt="https://bitlap.org"/>
梦境迷离's avatar
梦境迷离 已提交
2

梦境迷离's avatar
梦境迷离 已提交
3
# smt
I
IceMimosa 已提交
4

梦境迷离's avatar
梦境迷离 已提交
5
| Project Stage | CI              | Codecov                                   |
梦境迷离's avatar
梦境迷离 已提交
6
|---------------|-----------------|-------------------------------------------|
梦境迷离's avatar
梦境迷离 已提交
7
| ![Stage]      | ![CI][Badge-CI] | [![codecov][Badge-Codecov]][Link-Codecov] |
8

梦境迷离's avatar
梦境迷离 已提交
9 10 11
| Scaladex                                                      | Jetbrains Plugin                              | Nexus Snapshots                                                  |
|---------------------------------------------------------------|-----------------------------------------------|------------------------------------------------------------------|
| [![smt Scala version support][Badge-Scaladex]][Link-Scaladex] | [![Version][Badge-Jetbrains]][Link-Jetbrains] | [![Sonatype Nexus (Snapshots)][Badge-Snapshots]][Link-Snapshots] |
I
IceMimosa 已提交
12

梦境迷离's avatar
梦境迷离 已提交
13
Motivation
梦境迷离's avatar
梦境迷离 已提交
14
--
梦境迷离's avatar
梦境迷离 已提交
15

梦境迷离's avatar
梦境迷离 已提交
16
Learn Scala macro and abstract syntax tree.
梦境迷离's avatar
梦境迷离 已提交
17

梦境迷离's avatar
梦境迷离 已提交
18
> The project is currently experimental
梦境迷离's avatar
梦境迷离 已提交
19

梦境迷离's avatar
梦境迷离 已提交
20
[中文说明](./README_CN.md) | [English](./README.md)
21

梦境迷离's avatar
梦境迷离 已提交
22
# Environment
23

梦境迷离's avatar
梦境迷离 已提交
24
- Compile passed in Java 8、11
梦境迷离's avatar
梦境迷离 已提交
25
- Compile passed in Scala 2.11.12、2.12.14、2.13.8
26

梦境迷离's avatar
梦境迷离 已提交
27 28 29 30 31 32
# Document

[https://bitlap.org/en-US/lab/smt](https://bitlap.org/en-US/lab/smt)

# How to use

梦境迷离's avatar
梦境迷离 已提交
33
## csv
梦境迷离's avatar
梦境迷离 已提交
34

梦境迷离's avatar
梦境迷离 已提交
35
- `Converter` A basic CSV converter.
梦境迷离's avatar
梦境迷离 已提交
36 37
- `CsvableBuilder` Support for converting Scala`case class`to one CSV line in a custom way.
- `ScalableBuilder` Support for converting one CSV line to Scala`case class`in a custom way.
梦境迷离's avatar
梦境迷离 已提交
38
- `CsvFormat` Custom format and TSV file support.
梦境迷离's avatar
梦境迷离 已提交
39 40 41
- Zero dependency, type-safe

```scala
梦境迷离's avatar
梦境迷离 已提交
42
"org.bitlap" %% "smt-csv" % "<VERSION>" // since 0.5.2
梦境迷离's avatar
梦境迷离 已提交
43 44 45
```

## csv-derive
46

梦境迷离's avatar
梦境迷离 已提交
47
- `DeriveCsvConverter` Automatically derive`Converter`instances for Scala`case class`
梦境迷离's avatar
梦境迷离 已提交
48 49

```scala
梦境迷离's avatar
梦境迷离 已提交
50
"org.bitlap" %% "smt-csv-derive" % "<VERSION>" // since 0.5.2
梦境迷离's avatar
梦境迷离 已提交
51 52 53
```

## tools
54 55 56 57 58 59

- `@toString`
- `@json`
- `@builder`
- `@log`
- `@apply`
梦境迷离's avatar
梦境迷离 已提交
60
- `@constructor`
梦境迷离's avatar
梦境迷离 已提交
61
- `@equalsAndHashCode`
62
- `@jacksonEnum`
梦境迷离's avatar
梦境迷离 已提交
63
- `@elapsed`
64
- `@javaCompatible`
梦境迷离's avatar
梦境迷离 已提交
65
- `ProcessorCreator`
梦境迷离's avatar
梦境迷离 已提交
66

梦境迷离's avatar
梦境迷离 已提交
67
> The intellij plugin named `Scala-Macro-Tools` in marketplace.
68

梦境迷离's avatar
梦境迷离 已提交
69
```scala
梦境迷离's avatar
梦境迷离 已提交
70
"org.bitlap" %% "smt-annotations" % "<VERSION>" // named smt-annotations since 0.6.0 
梦境迷离's avatar
梦境迷离 已提交
71
```
72

梦境迷离's avatar
梦境迷离 已提交
73
## cacheable
梦境迷离's avatar
梦境迷离 已提交
74 75 76 77 78

A cache like Spring `@Cacheable` and `@cacheEvict` based on zio. It has no implementation of storage media.

- `@cacheable` / `Cache.apply`
- `@cacheEvict` / `Cache.evict`
梦境迷离's avatar
梦境迷离 已提交
79 80 81

```scala
// cache API, include dependencies: zio, zio-streams, zio-logging
梦境迷离's avatar
梦境迷离 已提交
82
"org.bitlap" %% "smt-cacheable" % "<VERSION>" // not support Scala2.11.x
梦境迷离's avatar
梦境迷离 已提交
83 84
```

梦境迷离's avatar
梦境迷离 已提交
85 86
## cacheable-redis

梦境迷离's avatar
梦境迷离 已提交
87
A distributed cache based on zio and zio-redis. It needs `cacheable` module.
梦境迷离's avatar
梦境迷离 已提交
88

梦境迷离's avatar
梦境迷离 已提交
89
> TODO Not unavailable, no distributed lock
梦境迷离's avatar
梦境迷离 已提交
90 91

```scala
梦境迷离's avatar
梦境迷离 已提交
92
// distributed cache, include dependencies: zio-redis, config, zio-schema, zio-schema-json, optional (zio-schema-derivation for case class)
梦境迷离's avatar
梦境迷离 已提交
93
// dependsOn `smt-cacheable`
梦境迷离's avatar
FIX  
梦境迷离 已提交
94
"org.bitlap" %% "smt-cacheable-redis" % "<VERSION>" // not support Scala2.11.x
梦境迷离's avatar
梦境迷离 已提交
95 96
```

梦境迷离's avatar
梦境迷离 已提交
97 98
## cacheable-caffeine

梦境迷离's avatar
梦境迷离 已提交
99
A memory cache based on zio and caffeine. It needs `cacheable` module.
梦境迷离's avatar
梦境迷离 已提交
100 101 102

```scala
// local cache, include dependencies: config, caffeine
梦境迷离's avatar
梦境迷离 已提交
103
// dependsOn `smt-cacheable`
梦境迷离's avatar
FIX  
梦境迷离 已提交
104
"org.bitlap" %% "smt-cacheable-caffeine" % "<VERSION>" // not support Scala2.11.x
梦境迷离's avatar
梦境迷离 已提交
105 106
```

梦境迷离's avatar
梦境迷离 已提交
107
The artefacts have been uploaded to Maven Central. Importing the library into your build system (e.g gradle, sbt), is not enough. You need to follow an extra step.
梦境迷离's avatar
梦境迷离 已提交
108

梦境迷离's avatar
梦境迷离 已提交
109 110 111
| Scala 2.11                   | Scala 2.12                   | Scala 2.13                                          |
| ---------------------------- | ---------------------------- | --------------------------------------------------- |
| Import macro paradise plugin | Import macro paradise plugin | Enable compiler flag `-Ymacro-annotations` required |
梦境迷离's avatar
梦境迷离 已提交
112 113 114 115 116

```scala
addCompilerPlugin("org.scalamacros" % "paradise_<your-scala-version>" % "<plugin-version>")
```

梦境迷离's avatar
梦境迷离 已提交
117
Where `<your-scala-version>` must be the full scala version. For example 2.12.13, and not 2.12.
梦境迷离's avatar
梦境迷离 已提交
118

梦境迷离's avatar
梦境迷离 已提交
119
If that doesn't work, google for alternatives.
梦境迷离's avatar
梦境迷离 已提交
120

梦境迷离's avatar
梦境迷离 已提交
121
In version scala`2.13.x`, the functionality of macro paradise has been included in the scala compiler directly. However,
梦境迷离's avatar
梦境迷离 已提交
122
you must still enable the compiler flag `-Ymacro-annotations`.
梦境迷离's avatar
梦境迷离 已提交
123 124

[Stage]: https://img.shields.io/badge/Project%20Stage-Experimental-yellow.svg
梦境迷离's avatar
梦境迷离 已提交
125 126
[Badge-CI]: https://github.com/bitlap/smt/actions/workflows/ScalaCI.yml/badge.svg
[Badge-Scaladex]: https://index.scala-lang.org/bitlap/smt/smt-annotations/latest-by-scala-version.svg?platform=jvm
梦境迷离's avatar
梦境迷离 已提交
127
[Badge-Jetbrains]: https://img.shields.io/jetbrains/plugin/v/17202-scala-macro-tools
梦境迷离's avatar
梦境迷离 已提交
128 129
[Badge-Codecov]: https://codecov.io/gh/bitlap/smt/branch/master/graph/badge.svg?token=IA596YRTOT
[Badge-Snapshots]: https://img.shields.io/nexus/s/org.bitlap/smt-annotations_2.13?server=https%3A%2F%2Fs01.oss.sonatype.org
梦境迷离's avatar
梦境迷离 已提交
130 131

[Link-Jetbrains]: https://plugins.jetbrains.com/plugin/17202-scala-macro-tools
梦境迷离's avatar
梦境迷离 已提交
132 133
[Link-Codecov]: https://codecov.io/gh/bitlap/smt
[Link-Scaladex]: https://index.scala-lang.org/bitlap/smt/smt-annotations
梦境迷离's avatar
梦境迷离 已提交
134
[Link-Snapshots]: https://s01.oss.sonatype.org/content/repositories/snapshots/org/bitlap/