apache / apache/maven-resolver

[MRESOLVER-271] Delay the download of a file until it is first accessed

Open
#762 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
152
Forks
160
Avg merge
1d 4h
Merged PRs (30d)
49

Description

**[Christoph Läubrich](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=laeubi)** opened **[MRESOLVER-271](https://issues.apache.org/jira/browse/MRESOLVER-271?redirect=false)** and commented

As described here https://issues.apache.org/jira/browse/MNG-7538 it would be good to have files be "lazy resolved":

Currently there is ```java
org.eclipse.aether.artifact.Artifact.setFile(File)

```that is used while resolving an Artifact against a remote repository and that points to an exiting file in the local repository.

This approach has the drawback, that during resolving an Artifact it needs to be fully downloaded, even though it might not be used (yet) if one likes to find out if it is resolvable and the meta-data would be enough to e.g. resolve it and its dependencies.

I therefore like to suggest supporting a way of a lazy-download in the following way:

1. There is a new method ```java
org.eclipse.aether.artifact.Artifact.setFileSupplier(Supplier supplier)
```

2.

```java
```

org.eclipse.aether.artifact.Artifact.getFile()

```first checks if there is a file already set, or otherwise init it by calling the supplier if given
3.There is a new method ```java
org.eclipse.aether.artifact.Artifact.hasFile()
``` that returns true if there is either a file set or a file supplier
```

---

**Issue Links:**
- [MNG-7538](https://issues.apache.org/jira/browse/MNG-7538) Delay the download of a file until it is first accessed
(_**"blocks"**_)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with org.eclipse.aether.artifact.Artifact and its implementations, then trace where resolving currently assigns a File. Check the linked MNG-7538 context before defining the API behavior. Done means supporting a file supplier, lazy initialization from getFile(), and hasFile() reporting either a file or supplier without downloading unused artifacts.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.