Skip to content

Commit

Permalink
doc: about gradle java-version
Browse files Browse the repository at this point in the history
Signed-off-by: CaiJingLong <cjl_spy@163.com>
  • Loading branch information
CaiJingLong committed Nov 10, 2023
1 parent 943d7c1 commit 736c072
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
16 changes: 16 additions & 0 deletions docs/src/photo_manager/gradle/java-version/index.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: "Configuring Java Version in photo_manager"
weight: 1
---

To ensure compatibility with older versions of AGP/flutter SDK, `photo_manager` supports configuring the project's Java version through configuration files, environment variables, and other methods.

It looks for the Java version in the following order:

1. Configuration in `gradle.properties` using the `java.version` property. The value should be in the format of a Java version number, such as `1.8`, `11`, `17`, `21`, etc.
2. Using the `JAVA_HOME` environment variable, which should point to the installation path of the JDK. Typically, the Java executable is located at `$JAVA_HOME/bin/java`.
3. Configuration in `gradle.properties` using the `java.home` property.
4. Reading the runtime property `java.home` of the JDK.
5. If none of the above is found, it defaults to using `JavaVersion.current()`.

Steps 4 and 5 should use the JDK configured in the Gradle settings, which is usually the same.
18 changes: 18 additions & 0 deletions docs/src/photo_manager/gradle/java-version/index.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: "photo_manager 中 java version 的配置方式"
weight: 1
---

photo_manager 为了保证旧版本 AGP/flutter SDK 的兼容性
所以支持通过配置文件/环境变量等方式来配置项目的 java 版本

它们会按照如下的顺序来查找 java 版本:

1. 通过 `gradle.properties` 中的 `java.version` 配置,它的值应该是一个 java 版本号的字符格式
例如: `1.8` `11` `17` `21`
2. 通过 `JAVA_HOME` 环境变量,它应该是一个 jdk 的安装路径,java 一般位于 `$JAVA_HOME/bin/java`
3. 通过 `gradle.properties` 中的 `java.home` 来配置
4. 通过读取 JDK 的运行时属性 `java.home` 来读取
5. 如果以上都没有找到,那么会使用 JavaVersion.current()

以上的4、5步骤应该使用的是 Gradle 配置中的 JDK,通常是相同的

0 comments on commit 736c072

Please sign in to comment.