mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 22:30:54 +01:00
Offline Gradle build #44
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rafaelrc7 on GitHub (Feb 7, 2024).
Hello, I'm having trouble setting up an offline gradle build.
First I run gradle normally, using the command described in #66 to fetch all dependencies.
Then, I convert the downloaded dependencies into a local maven repository, that I'll call "deps".
And then, I edit the following files:
Changing
mavenCentralintomaven { url = uri("/path/to/deps") }.Then I try running
gradle --offline --no-daemon build. It manages to run most of the configuration step, showing that it manages to find the dependencies when it looks into the local repo. However, it then fails when trying to resolve dependencies of the step:pkl-cli:runtimeClasspathwith the following error:By the looks of the error, it seems that, for some reason, this step is still trying to reach
mavenCentral()instead of deps. How can I change thepkl-clirepositories intodeps?@bioball commented on GitHub (Feb 26, 2024):
The intricacies of Gradle aren't my area of expertise.
However, I tried building locally without editing any of the
mavenCentralfiles, and it is passing on my machine.Have you tried building this without making those source file changes?
@StefMa commented on GitHub (Feb 26, 2024):
Some dependencies will be downloaded as part of a task. So running the
dependenciesgradle task will only download the dependencies that are "normally" declared in the build scripts. However it might be the case that some tasks download dependencies "on the fly". These are missing now, if you run thebuildtask.To download all required dependencies for the
buildtask, run thebuildtask withmavenCentraldeclared 😁 afterwards all of them "should be available"™ and you can run thebuildtask offline as well...I guess 😁 at least worth to try.
It could also happen that some plugins will add the
mavenCentralrepository by themself to download dependencies. In this case it might be not possible to buildpklwithout internet...@bioball commented on GitHub (Feb 26, 2024):
From someone more knowledgable than me about Gradle:
@rafaelrc7 commented on GitHub (Mar 8, 2024):
Thank you both for the input! However, I believe I did not explain fully what the issue is... To give a bit more of context, I am trying to package pkl for nixpkgs. In nixpkgs, reproducibility is a necessity, and so extra steps are taken to package software. The process with gradle generally involves first building a derivation (a nix package) that is a local maven repository with the package dependencies, that was done, partly thanks to @bioball by answering https://github.com/apple/pkl/issues/66 .
The dependencies derivation is then used as a local maven repo. To do so, the gradle files are patched to point to this repo (simply a path in the file system). However, it seems that even by editting any gradle file
:pkl-cli:runtimeClasspathtask still refuses to look up for thecom.github.ajalt.clikt:clikt-jvm:3.5.1dependency in the local repo. I checked and this particular dependency is downloaded and is available in the local repo... It just seems that the change to the list of repos is not affecting this task.@bioball commented on GitHub (Mar 8, 2024):
Have you tried just running the dependencies command, and then re-building in offline mode? I've found that I can build in offline mode just fine. Or is that not good enough for nix?
@rafaelrc7 commented on GitHub (Mar 9, 2024):
The issue is that during the nix derivation build process, the dependencies are downloaded in an isolated environment, then the dependencies, and only the dependencies, are extracted into a local maven repo. Finally, the package is built in other isolated environment, so the cache is a new one, like building pkl for the first time. In theory, all dependencies are available in the local repository, however the aforementioned task seems to ignore it...
I tried adding the local repo to:
but it still does not apply to all tasks.
@rafaelrc7 commented on GitHub (Jul 20, 2024):
Ok, I finally understood the problem and why it seemed that offline builds were not working. As discussed in https://github.com/NixOS/nixpkgs/pull/286658#issuecomment-2240070303 some tasks as
spotlessCheckdepend on dynamic dependencies and thus the solution is to skip it.Thanks for the help!