[MNG-7538] Delay the download of a file until it is first accessed
- Dominant language
- Java
- Stars
- 5.3k
- Forks
- 3.1k
- Avg merge
- 20h 42m
- Merged PRs (30d)
- 297
Description
**[Christoph Läubrich](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=laeubi)** opened **[MNG-7538](https://issues.apache.org/jira/browse/MNG-7538?redirect=false)** and commented
Currently there is ```java
org.apache.maven.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.apache.maven.artifact.Artifact.setFileSupplier(Supplier supplier)
```
2.
```java
```
org.apache.maven.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.apache.maven.artifact.Artifact.hasFile()
``` that returns true if there is either a file set or a file supplier
As there is a close relation with org.eclipse.aether.artifact.Artifact a similar change might be required there as well...
```
---
**Issue Links:**
- [MRESOLVER-271](https://issues.apache.org/jira/browse/MRESOLVER-271) Delay the download of a file until it is first accessed
(_**"is blocked by"**_)
Contributor guide
Assessment
This issue has not been assessed yet.