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

梦境迷离's avatar
梦境迷离 已提交
3
# scala-macro-tools
I
IceMimosa 已提交
4

5 6 7 8 9 10 11
| CI                                                                                                                                                                         | Codecov                                                                                                                                                     |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [![Build](https://github.com/bitlap/scala-macro-tools/actions/workflows/ScalaCI.yml/badge.svg)](https://github.com/bitlap/scala-macro-tools/actions/workflows/ScalaCI.yml) | [![codecov](https://codecov.io/gh/bitlap/scala-macro-tools/branch/master/graph/badge.svg?token=IA596YRTOT)](https://codecov.io/gh/bitlap/scala-macro-tools) |

| Scaladex                                                                                                                                                                                                                                | Maven Central                                                                                                                                               | Jetbrains Plugin                                                                                                                              |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ----------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| [![scala-macro-tools Scala version support](https://index.scala-lang.org/bitlap/scala-macro-tools/scala-macro-tools/latest-by-scala-version.svg?platform=jvm)](https://index.scala-lang.org/bitlap/scala-macro-tools/scala-macro-tools) | [![Maven Central](https://img.shields.io/maven-central/v/org.bitlap/scala-macro-tools_2.13.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.bitlap%22%20AND%20a:%22scala-macro-tools_2.13%22) | [![Version](https://img.shields.io/jetbrains/plugin/v/17202-scala-macro-tools)](https://plugins.jetbrains.com/plugin/17202-scala-macro-tools) |
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 25
- Compile passed in Java 8、11
- Compile passed in Scala 2.11.12、2.12.14、2.13.6
26

27 28 29
# Module Features

## `tools`
30 31 32 33 34 35

- `@toString`
- `@json`
- `@builder`
- `@log`
- `@apply`
梦境迷离's avatar
梦境迷离 已提交
36
- `@constructor`
梦境迷离's avatar
梦境迷离 已提交
37
- `@equalsAndHashCode`
38
- `@jacksonEnum`
梦境迷离's avatar
梦境迷离 已提交
39
- `@elapsed`
40
- `@javaCompatible`
梦境迷离's avatar
梦境迷离 已提交
41
- `ProcessorCreator`
梦境迷离's avatar
梦境迷离 已提交
42

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

45 46 47 48 49 50 51 52 53
## `cacheable-core`

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

- `@cacheable` / `Cache.apply`
- `@cacheEvict` / `Cache.evict`

## `cacheable-caffeine`

梦境迷离's avatar
梦境迷离 已提交
54
A memory cache based on zio and caffeine. It needs `cacheable-core` module.
55 56 57

## `cacheable-redis`

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

梦境迷离's avatar
梦境迷离 已提交
60 61 62
# Document

[https://bitlap.org/lab/smt](https://bitlap.org/lab/smt)
63

梦境迷离's avatar
梦境迷离 已提交
64
# How to use
梦境迷离's avatar
梦境迷离 已提交
65

梦境迷离's avatar
梦境迷离 已提交
66
Add library dependency
梦境迷离's avatar
梦境迷离 已提交
67

梦境迷离's avatar
梦境迷离 已提交
68
```scala
69 70 71 72 73 74 75 76 77
"org.bitlap" %% "smt-tools" % "<VERSION>" // named smt-tools since 0.4.0 

// when you need cacheable module (not support Scala 2.11.x)
// include dependencies: zio,zio-streams,zio-logging
"org.bitlap" %% "smt-cacheable-core" % "<VERSION>" 
// local cache, include dependencies: config, caffeine
"org.bitlap" %% "smt-cacheable-caffeine" % "<VERSION>" 
// distributed cache, include dependencies: zio-redis,config,zio-schema, optional (zio-schema-protobuf,zio-schema-derivation for case class)
"org.bitlap" %% "smt-cacheable-redis" % "<VERSION>"
梦境迷离's avatar
梦境迷离 已提交
78 79
```

梦境迷离's avatar
梦境迷离 已提交
80
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
梦境迷离 已提交
81

梦境迷离's avatar
梦境迷离 已提交
82 83 84
| 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
梦境迷离 已提交
85 86 87 88 89

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

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

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

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