Sud*_*hir 5 maven-3 github-actions
每次触发我的构建工作流程时,都会下载Maven依赖项。
Travis CI提供了一种缓存Maven存储库的方法。Github操作是否提供允许缓存Maven存储库的类似功能?
小智 27
为了完整起见,这是一个如何在后续构建中缓存本地 Maven 存储库的示例:
steps:
# Typical Java workflow steps
- uses: actions/checkout@v1
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
# Step that does that actual cache save and restore
- uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Step that runs the tests
- name: Run tests
run: mvn test
Run Code Online (Sandbox Code Playgroud)
有关更多详细信息,请参阅此页面。
小智 9
截至 2021 年,最新的官方答案是
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
Run Code Online (Sandbox Code Playgroud)
摘自官方 github 示例:https://github.com/actions/cache/blob/master/examples.md#java---maven
小智 8
对于 Maven,您现在可以使用它setup-java来缓存依赖项。例子:
- uses: actions/setup-java@v2.3.1
name: Install Java
with:
java-version: 8
distribution: 'adopt'
cache: 'maven'
Run Code Online (Sandbox Code Playgroud)
setup-*请注意,与其他: node、python和相同ruby。
小智 6
显然,截至 2019 年 9 月 10 日,Github Actions 中不存在构建依赖项的缓存。Github 工作人员承认此功能是必要的,并回复说“我们正在努力在工作流执行之间缓存包和工件,我们将在 11 月中旬 [2019] 之前完成它。”
来源:https : //github.community/t5/GitHub-Actions/Caching-files-between-GitHub-Action-executions/mp/30974/highlight/true#M630
| 归档时间: |
|
| 查看次数: |
340 次 |
| 最近记录: |