Skip to content

Commit

Permalink
= improve docs
Browse files Browse the repository at this point in the history
- add IDE setting in dev guide
- rename profile name in pom
  • Loading branch information
oldratlee committed Aug 14, 2020
1 parent cad2bbc commit 9a41a04
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 29 deletions.
2 changes: 0 additions & 2 deletions README-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,8 @@ Compilation/build environment require **_`JDK 8~11`_**; Compilation can be perfo
```bash
# Run test case
./mvnw test

# Compile and package
./mvnw package

# Run test case, compile and package, install TTL library to local Maven
./mvnw install

Expand Down
18 changes: 3 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
- [`Java`的启动参数配置](#java%E7%9A%84%E5%90%AF%E5%8A%A8%E5%8F%82%E6%95%B0%E9%85%8D%E7%BD%AE)
- [🔌 Java API Docs](#-java-api-docs)
- [🍪 Maven依赖](#-maven%E4%BE%9D%E8%B5%96)
- [🔨 关于编译构建开发环境](#-%E5%85%B3%E4%BA%8E%E7%BC%96%E8%AF%91%E6%9E%84%E5%BB%BA%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83)
- [如何编译构建](#%E5%A6%82%E4%BD%95%E7%BC%96%E8%AF%91%E6%9E%84%E5%BB%BA)
- [如何用`IDE`开发](#%E5%A6%82%E4%BD%95%E7%94%A8ide%E5%BC%80%E5%8F%91)
- [🔨 关于编译构建与开发环境](#-%E5%85%B3%E4%BA%8E%E7%BC%96%E8%AF%91%E6%9E%84%E5%BB%BA%E4%B8%8E%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83)
- [❓ FAQ](#-faq)
- [🗿 更多文档](#-%E6%9B%B4%E5%A4%9A%E6%96%87%E6%A1%A3)
- [📚 相关资料](#-%E7%9B%B8%E5%85%B3%E8%B5%84%E6%96%99)
Expand Down Expand Up @@ -312,20 +310,16 @@ java -javaagent:path/to/ttl-foo-name-changed.jar \

可以在 [search.maven.org](https://search.maven.org/search?q=g:com.alibaba%20AND%20a:transmittable-thread-local&core=gav) 查看可用的版本。

# 🔨 关于编译构建开发环境

## 如何编译构建
# 🔨 关于编译构建与开发环境

编译构建的环境要求: **_`JDK 8~11`_**;用`Maven`常规的方式执行编译构建即可:
\# 在工程中已经包含了符合版本要求的`Maven`,直接运行 **_工程根目录下的`mvnw`_**;并不需要先手动自己安装好`Maven`

```bash
# 运行测试Case
./mvnw test

# 编译打包
./mvnw package

# 运行测试Case、编译打包、安装TTL库到Maven本地
./mvnw install

Expand All @@ -334,13 +328,7 @@ java -javaagent:path/to/ttl-foo-name-changed.jar \
mvn install
```

## 如何用`IDE`开发

如果使用`IDE`来开发(如`IntelliJ IDEA`):
注意用`IDE`打开 **_工程根目录下的`pom4ide.xml`文件_**,而不是`pom.xml`;以避免`IDE`报使用`JDK 8`的标准库类找不到。

`IDE`支持不好,要换一个`POM`文件,原因是:
`TTL`的代码实现使用了`JDK 8`的标准库类,但编译成`Java 6`版本的类文件。
如何用`IDE`来开发时注意点,更多说明参见 [文档 如何用`IDE`开发 - Developer Guide](docs/developer-guide.md#%E5%A6%82%E4%BD%95%E7%94%A8ide%E5%BC%80%E5%8F%91)

# ❓ FAQ

Expand Down
4 changes: 2 additions & 2 deletions docs/developer-guide-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

# 📌 Framework/Middleware integration to `TTL` transmittance

[`TransmittableThreadLocal.Transmitter`](../src/main/java/com/alibaba/ttl/TransmittableThreadLocal.java#L240) to capture all `TTL` values of current thread and replay them in other thread.
[`TransmittableThreadLocal.Transmitter`](../src/main/java/com/alibaba/ttl/TransmittableThreadLocal.java#L240) to capture all `TTL` values of current thread and replay them in another thread.

There are following methods:

- `capture`: capture all `TTL` values in current thread
- `replay`: replay the captured `TTL` values in current thread, and return the backup `TTL` values before replay
- `replay`: replay the captured `TTL` values in the current thread, and return the backup `TTL` values before replay
- `restore`: restore `TTL` values before replay

Sample code:
Expand Down
58 changes: 58 additions & 0 deletions docs/developer-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
- [`Java Agent`方式对应用代码无侵入](#java-agent%E6%96%B9%E5%BC%8F%E5%AF%B9%E5%BA%94%E7%94%A8%E4%BB%A3%E7%A0%81%E6%97%A0%E4%BE%B5%E5%85%A5)
- [已有`Java Agent`中嵌入`TTL Agent`](#%E5%B7%B2%E6%9C%89java-agent%E4%B8%AD%E5%B5%8C%E5%85%A5ttl-agent)
- [👢 Bootstrap上添加通用库的`Jar`的问题及解决方法](#-bootstrap%E4%B8%8A%E6%B7%BB%E5%8A%A0%E9%80%9A%E7%94%A8%E5%BA%93%E7%9A%84jar%E7%9A%84%E9%97%AE%E9%A2%98%E5%8F%8A%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95)
- [🔨 关于编译构建与`IDE`开发](#-%E5%85%B3%E4%BA%8E%E7%BC%96%E8%AF%91%E6%9E%84%E5%BB%BA%E4%B8%8Eide%E5%BC%80%E5%8F%91)
- [如何编译构建](#%E5%A6%82%E4%BD%95%E7%BC%96%E8%AF%91%E6%9E%84%E5%BB%BA)
- [如何用`IDE`开发](#%E5%A6%82%E4%BD%95%E7%94%A8ide%E5%BC%80%E5%8F%91)
- [`IntelliJ IDEA`关闭检查方法](#intellij-idea%E5%85%B3%E9%97%AD%E6%A3%80%E6%9F%A5%E6%96%B9%E6%B3%95)
- [其它`IDE`的解决方法](#%E5%85%B6%E5%AE%83ide%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95)
- [📚 相关资料](#-%E7%9B%B8%E5%85%B3%E8%B5%84%E6%96%99)
- [Jdk core classes](#jdk-core-classes)
- [Java Agent](#java-agent)
Expand Down Expand Up @@ -166,6 +171,59 @@ public final class YourXxxAgent {

这样就不需要依赖外部的`Javassist`依赖,也规避了依赖冲突的问题。

# 🔨 关于编译构建与`IDE`开发

## 如何编译构建

编译构建的环境要求: **_`JDK 8~11`_**;用`Maven`常规的方式执行编译构建即可:
\# 在工程中已经包含了符合版本要求的`Maven`,直接运行 **_工程根目录下的`mvnw`_**;并不需要先手动自己安装好`Maven`

```bash
# 运行测试Case
./mvnw test
# 编译打包
./mvnw package
# 运行测试Case、编译打包、安装TTL库到Maven本地
./mvnw install

#####################################################
# 如果使用你自己安装的`Maven`,版本要求:maven 3.3.9+
mvn install
```

## 如何用`IDE`开发

`TTL`的代码实现使用了`JDK 8`的标准库类,但编译成`Java 6`版本的类文件。即

- `Java`文件是`Java`语言版本 是 `Java 6`
- 但编译依赖的`Java API`/标准库(由`JVM`提供) 需要是 `Java 8`/`JVM 8`
- 2者不一致的。

现代的`IDE`(如`IntelliJ IDEA`)一般会缺省做 语言版本 与 `API` 的检查:

- 如何使用了高于语言版本的标准库类,`IDE`会报错。
- 以避免在语言版本`JVM`运行时,可能会出标准类找不到的风险。

可以在`IDE`设置中,关闭这个『语言版本 与 `API`』检查。

### `IntelliJ IDEA`关闭检查方法

在设置中关闭【`Inspections` - `Usages of API which isn't available at the configured language level`】:

![1-preferences](https://user-images.githubusercontent.com/1063891/90227365-02d85e00-de47-11ea-94f6-7ac02468d25d.png)

也可以通过【`Find Actions...`<kbd>cmd + shift + A</kbd>】,更方便快速完成设置:

![2-action-setting](https://user-images.githubusercontent.com/1063891/90227383-0966d580-de47-11ea-99c6-188878974695.png)

### 其它`IDE`的解决方法

其它`IDE`(如`Eclipse`)可以找一下设置方法,以关闭这个『语言版本 与 `API`』检查。

如果没有找到`IDE`的设置方法,也可以用下面的方法来 **`workaround`**: 😂

打开 **_工程根目录下的`pom4ide.xml`文件_**(修改了`Java`文件的语言版本),而不是`pom.xml`

# 📚 相关资料

## Jdk core classes
Expand Down
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,11 @@
<version>4.0.4</version>
</plugin>
<!--
official docs: https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html
official docs: https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html
add maven-enforce-plugin to make sure the right jdk is used
https://stackoverflow.com/a/18420462/922688
-->
add maven-enforce-plugin to make sure the right jdk is used
https://stackoverflow.com/a/18420462/922688
-->
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
Expand Down Expand Up @@ -644,7 +644,7 @@
</build>
</profile>
<profile>
<id>force-jdk-11+when-do-release</id>
<id>force-jdk11-when-release</id>
<activation>
<property>
<name>performRelease</name>
Expand Down
10 changes: 5 additions & 5 deletions pom4ide.xml
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,11 @@
<version>4.0.4</version>
</plugin>
<!--
official docs: https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html
official docs: https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html
add maven-enforce-plugin to make sure the right jdk is used
https://stackoverflow.com/a/18420462/922688
-->
add maven-enforce-plugin to make sure the right jdk is used
https://stackoverflow.com/a/18420462/922688
-->
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
Expand Down Expand Up @@ -644,7 +644,7 @@
</build>
</profile>
<profile>
<id>force-jdk-11+when-do-release</id>
<id>force-jdk11-when-release</id>
<activation>
<property>
<name>performRelease</name>
Expand Down

0 comments on commit 9a41a04

Please sign in to comment.