Skip to content

Comments

[WIP] Refactor Java module with provider-based catalog caching#86

Draft
BegoniaHe wants to merge 15 commits intoHydroRoll-Team:refactor/migrate-to-reactfrom
BegoniaHe:refactor/java-provider
Draft

[WIP] Refactor Java module with provider-based catalog caching#86
BegoniaHe wants to merge 15 commits intoHydroRoll-Team:refactor/migrate-to-reactfrom
BegoniaHe:refactor/java-provider

Conversation

@BegoniaHe
Copy link
Contributor

@BegoniaHe BegoniaHe commented Feb 5, 2026

描述

  • 本 PR 基于 [WIP] Export Rust core types to TypeScript with ts-rs and update CI #77 ,为 Java 子模块引入缓存与结构重构,改善提供者(provider)职责划分并为后续扩展(更多 provider)做准备。
  • 新增 cache.rs 实现 Java catalog 的本地缓存(24 小时有效期)。
  • 将原来的 detection.rs 拆分为平台子模块(detection/{linux,macos,windows,unix,common}.rs),并新增 install.rs 以整理安装流程。
  • 调整 persistence.rsproviders/adoptium.rsvalidation.rs 以配合重构。

更改类型

  • Bug 修复
  • 新功能
  • 代码重构
  • 性能优化
  • 文档更新
  • 其他

LLM 生成代码声明

  • 此 PR 包含 LLM 生成的代码

相关 Issue


更改内容

后端 (Rust)

  • 新增:cache.rs(JavaCatalog 缓存)。
  • 重构:拆分 java::detection 到平台实现,新增 install.rs
  • 更新:persistence.rsproviders/adoptium.rsvalidation.rs 等,整理 provider 接口与实现。

前端 (Svelte)

配置


测试

测试环境

  • 操作系统:Windows 11(本地开发机)
  • DropOut 版本:0.1.24
  • Minecraft 版本:N/A
  • Mod 加载器:N/A

测试结果摘要

  • 本地运行 cargo test

running 81 tests
test result: ok. 81 passed; 0 failed; 0 ignored; finished in 0.25s

测试用例

  • 已在 Windows 上测试(单元测试通过)
  • 已在 macOS 上测试
  • 已在 Linux 上测试
  • 已测试原版 Minecraft
  • 已测试 Fabric
  • 已测试 Forge
  • 已测试游戏启动
  • 已测试登录流程
  • 已测试 Java 检测/下载(待前端完成后人工集成测试)

测试步骤

  1. 在项目根目录运行:cargo test
  2. 确认所有单元测试通过(81 / 81)

检查清单

代码质量

  • 我的代码遵循项目的代码风格指南
  • 我已对自己的代码进行了自审
  • 我已对难以理解的区域添加了注释(必要处)
  • 我的更改没有产生新的警告或错误(已运行 clippy/fmt)

测试验证

  • 我已在本地测试了我的更改
  • 我已添加测试来证明我的修复有效或功能正常工作(目前未新增测试)
  • 新的和现有的单元测试在本地通过
  • 我至少在一个目标平台上进行了更多手动测试(待补充)

文档更新

  • 我已相应地更新了文档(若需要将在后续 PR 补充)

依赖项

  • 我已检查没有添加不必要的依赖项

附加说明

  • 这是一次偏向内部架构的重构与性能改进,不含破坏性变更。后续可基于新的 provider 接口添加更多 Java 源(例如 Amazon Corretto, Liberica 等)。
  • 若需要我可以补充集成测试或在 macOS / Linux 上做额外验证。

维护者专用

  • 代码审查已完成
  • CI 检查通过
  • 准备合并

add src-tauri/src/core/java/cache.rs for Java catalog caching
reorganize provider interfaces and move detection/install changes
update persistence, adoptium provider and validation

Reviewed-by: Raptor mini (Preview)
Copilot AI review requested due to automatic review settings February 5, 2026 19:45
@vercel
Copy link

vercel bot commented Feb 5, 2026

@BegoniaHe is attempting to deploy a commit to the retrofor Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @BegoniaHe, your pull request is larger than the review limit of 150000 diff characters

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Java subsystem for the DropOut Minecraft launcher by introducing catalog caching, reorganizing provider architecture, and adding TypeScript bindings via ts-rs. Based on PR #77, it includes a new React-based UI (ui-new) alongside backend refactoring.

Changes:

  • Adds Java catalog caching with 24-hour validity (cache.rs)
  • Introduces provider trait pattern for extensible Java distribution support
  • Splits detection logic into platform-specific modules
  • Adds priority-based Java resolution for game launches
  • Generates TypeScript bindings for all core data structures
  • Introduces new React UI with Zustand state management

Reviewed changes

Copilot reviewed 101 out of 103 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src-tauri/src/core/java/cache.rs New 24-hour catalog caching with atomic file writes
src-tauri/src/core/java/provider.rs Provider trait for Java distributions
src-tauri/src/core/java/providers/adoptium.rs Adoptium provider implementation with parallel fetching
src-tauri/src/core/java/validation.rs Extracted validation logic with async support
src-tauri/src/core/java/persistence.rs User configuration persistence
src-tauri/src/core/java/priority.rs Priority-based Java resolution for launches
src-tauri/src/core/java/install.rs Extracted installation logic
src-tauri/src/core/java/detection/* Platform-specific detection modules
src-tauri/src/main.rs Updated to use new Java resolution and provider APIs
src-tauri/src/core/auth.rs Changed CLIENT_ID back to DropOut's own Azure app
packages/ui-new/* Complete new React-based UI implementation

setNewInstanceName("");
};

const confirmEdit = async () => {
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable confirmEdit.

Copilot uses AI. Check for mistakes.
@HsiangNianian HsiangNianian changed the base branch from main to refactor/migrate-to-react February 5, 2026 23:19
BegoniaHe and others added 4 commits February 6, 2026 02:59
- Update .github/copilot-instructions.md

Reviewed-by: GitHub Copilot CLI
…ydroRoll-Team#88)

## Summary by Sourcery

Improve bilingual README structure and formatting for clarity and
consistency.

Documentation:
- Add cross-links between English and Chinese READMEs for easier
language switching.
- Normalize README formatting including roadmap link styling, spacing,
and license section presentation in both languages.
@HsiangNianian
Copy link
Member

@fu050409 @NtskwK Plz review this PR

HsiangNianian and others added 4 commits February 10, 2026 12:14
…Roll-Team#92)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: HsiangNianian <44714368+HsiangNianian@users.noreply.github.com>
Comment out the Musl platform configuration for CI.
@HsiangNianian
Copy link
Member

@SourceryAI title

@sourcery-ai sourcery-ai bot changed the title refactor(java): add java catalog cache and reorganize providers Refactor Java module with provider-based catalog caching Feb 15, 2026
@HsiangNianian HsiangNianian changed the title Refactor Java module with provider-based catalog caching [WIP] Refactor Java module with provider-based catalog caching Feb 15, 2026
Copilot AI and others added 3 commits February 15, 2026 16:34
…oll-Team#96)

# Description

MinGW linker fails on `resource.lib` because `tauri-build` generates
MSVC-format resources. MinGW requires COFF format. This PR adds
conditional resource compilation using `embed-resource` for GNU targets.

## Type of Change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] Documentation update
- [ ] UI/UX improvement
- [ ] Performance improvement
- [ ] Code refactoring (no functional changes)
- [ ] Configuration change
- [ ] Test addition or update

## LLM-Generated Code Disclosure

- [x] This PR contains LLM-generated code, and I **provide** quality
assurance
- [ ] This PR contains LLM-generated code, and I **do not provide**
quality assurance
- [ ] This PR does not contain LLM-generated code

## Related Issues

Fixes the Windows x86_64-pc-windows-gnu build failure in CI (Job ID:
63620685213)

## Changes Made

### Backend (Rust)

- N/A

### Frontend (Svelte)

- N/A

### Configuration

- **src-tauri/Cargo.toml**: Added `embed-resource = "2.4"` as
target-specific build dependency for `cfg(all(windows, target_env =
"gnu"))`
- **src-tauri/build.rs**: Added conditional resource compilation - calls
`embed_resource::compile()` for MinGW, preserves `tauri_build::build()`
for all targets
- **src-tauri/icon.rc**: Created Windows resource file referencing
`icons/icon.ico`

**Key implementation**:
```rust
fn main() {
    #[cfg(all(windows, target_env = "gnu"))]
    {
        embed_resource::compile("icon.rc", embed_resource::NONE);
    }
    tauri_build::build()
}
```

**Impact**: MSVC builds unchanged, Linux/macOS unaffected (dependency
not loaded), MinGW builds now generate COFF-compatible resources.

## Testing

### Test Environment

- **OS**: Ubuntu 22.04 (Linux validation)
- **DropOut Version**: 0.2.0-alpha.1
- **Minecraft Version Tested**: N/A (build-only fix)
- **Mod Loader**: N/A

### Test Cases

- [ ] Tested on Windows
- [ ] Tested on macOS
- [x] Tested on Linux
- [ ] Tested with vanilla Minecraft
- [ ] Tested with Fabric
- [ ] Tested with Forge
- [ ] Tested game launch
- [ ] Tested authentication flow
- [ ] Tested Java detection/download

### Steps to Test

1. Run `cargo check` on Linux (verified - passes)
2. CI validation pending: `semifold-ci.yaml` "Windows x86_64 (GNU)" job
should complete without linker errors
3. Manual Windows MinGW build verification recommended

## Checklist

### Code Quality

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] My changes generate no new warnings or errors

### Testing Verification

- [x] I have tested my changes locally
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [x] I have tested on at least one target platform

### Documentation

- [x] I have updated the documentation accordingly
- [ ] I have updated the README if needed
- [x] I have added/updated code comments where necessary

### Dependencies

- [x] I have checked that no unnecessary dependencies were added
- [x] All new dependencies are properly documented
- [x] `Cargo.lock` and/or `pnpm-lock.yaml` are updated (if dependencies
changed)

## Screenshots / Videos

N/A - build configuration change only

## Additional Notes

- Target-specific dependency prevents unnecessary bloat on non-Windows
platforms
- `embed-resource` generates COFF format compatible with
`x86_64-w64-mingw32-gcc`
- No runtime code changes - purely build-time fix

## Breaking Changes

None. Fully backward compatible.

---

**For Maintainers:**

- [ ] Code review completed
- [ ] CI checks passing
- [ ] Ready to merge

<!-- START COPILOT ORIGINAL PROMPT -->



<details>

<summary>Original prompt</summary>

> ## Problem
> 
> The Windows x86_64-pc-windows-gnu build is failing in the CI/CD
pipeline with a linker error:
> 
> ```
> error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
> note:
D:\a\DropOut\DropOut\target\x86_64-pc-windows-gnu\release\build\dropout-d2b2a5095bbadd51\out\resource.lib:
file not recognized: file format not recognized
> ```
> 
> This occurs because `tauri-build` generates `resource.lib` in a format
incompatible with the MinGW (GNU) toolchain. The file is likely being
created in MSVC format instead of the COFF format required by MinGW.
> 
> **Failing Job:** https://github.com/HydroRoll-Team/DropOut/actions
(Job ID: 63620685213)
> **Commit:** e6eb1bd
> **Target:** x86_64-pc-windows-gnu
> 
> ## Solution
> 
> Update the `build.rs` file to conditionally use `embed-resource` crate
when building for the GNU toolchain, which properly generates
MinGW-compatible resource files.
> 
> ### Changes Required
> 
> 1. **Update `src-tauri/Cargo.toml`**: Add `embed-resource` as a build
dependency for Windows GNU targets
> 2. **Update `src-tauri/build.rs`**: Implement conditional resource
compilation:
>    - Use `embed-resource` for `x86_64-pc-windows-gnu` target
>    - Continue using default `tauri-build` for MSVC targets
> 
> ### Implementation Details
> 
> **src-tauri/Cargo.toml** - Add to `[build-dependencies]`:
> ```toml
> [build-dependencies]
> tauri-build = { version = "2.0", features = [] }
> embed-resource = "2.4"
> ```
> 
> **src-tauri/build.rs** - Replace current content:
> ```rust
> fn main() {
> // For MinGW targets, use embed-resource to generate proper COFF
format
>     #[cfg(all(windows, target_env = "gnu"))]
>     {
>         embed_resource::compile("icon.rc", embed_resource::NONE);
>     }
>     
>     tauri_build::build()
> }
> ```
> 
> If `icon.rc` doesn't exist, create **src-tauri/icon.rc**:
> ```rc
> 1 ICON "icons/icon.ico"
> ```
> 
> ### Testing
> 
> After this fix:
> - Windows MSVC builds should continue working as before
> - Windows GNU (MinGW) builds should successfully link without the
"file format not recognized" error
> - The generated resource.lib will be in COFF format compatible with
`x86_64-w64-mingw32-gcc`
> 
> ### References
> 
> - Tauri issue tracker (similar issues):
https://github.com/tauri-apps/tauri/issues
> - embed-resource crate: https://crates.io/crates/embed-resource
> - MinGW resource compilation:
https://sourceforge.net/p/mingw-w64/wiki2/windres/
> 


</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>

<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for
you](https://github.com/HydroRoll-Team/DropOut/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: HsiangNianian <44714368+HsiangNianian@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants