mirror of
https://github.com/Mic92/nix-update.git
synced 2024-11-03 21:04:49 +03:00
Merge pull request #233 from anthonyroussel/maven
Add support for updating buildMavenPackage's mvnHash
This commit is contained in:
commit
c20ec18496
@ -20,6 +20,7 @@ designed to work with nixpkgs but also other package sets.
|
||||
- update buildGoModule's vendorHash/vendorSha256
|
||||
- update buildNpmPackage's npmDepsHash and npmConfigHook's npmDeps
|
||||
- update buildComposerProject's vendorHash
|
||||
- update buildMavenPackage's mvnHash
|
||||
- update fetchYarnDeps offlineCache output hash
|
||||
- update flake outputs (see `--flake`)
|
||||
- build and run the resulting package (see `--build`,
|
||||
|
@ -56,6 +56,7 @@ class Package:
|
||||
npm_deps: str | None
|
||||
yarn_deps: str | None
|
||||
composer_deps: str | None
|
||||
maven_deps: str | None
|
||||
tests: list[str]
|
||||
has_update_script: bool
|
||||
|
||||
@ -162,6 +163,7 @@ in {{
|
||||
composer_deps = pkg.composerRepository.outputHash or null;
|
||||
npm_deps = pkg.npmDeps.outputHash or null;
|
||||
yarn_deps = pkg.offlineCache.outputHash or null;
|
||||
maven_deps = pkg.fetchedMavenDeps.outputHash or null;
|
||||
tests = builtins.attrNames (pkg.passthru.tests or {{}});
|
||||
has_update_script = {has_update_script};
|
||||
src_homepage = pkg.src.meta.homepage or null;
|
||||
|
@ -271,6 +271,11 @@ def update_yarn_deps_hash(opts: Options, filename: str, current_hash: str) -> No
|
||||
replace_hash(filename, current_hash, target_hash)
|
||||
|
||||
|
||||
def update_maven_deps_hash(opts: Options, filename: str, current_hash: str) -> None:
|
||||
target_hash = nix_prefetch(opts, "fetchedMavenDeps")
|
||||
replace_hash(filename, current_hash, target_hash)
|
||||
|
||||
|
||||
def update_version(
|
||||
package: Package, version: str, preference: VersionPreference, version_regex: str
|
||||
) -> bool:
|
||||
@ -385,4 +390,7 @@ def update(opts: Options) -> Package:
|
||||
if package.yarn_deps:
|
||||
update_yarn_deps_hash(opts, package.filename, package.yarn_deps)
|
||||
|
||||
if package.maven_deps:
|
||||
update_maven_deps_hash(opts, package.filename, package.maven_deps)
|
||||
|
||||
return package
|
||||
|
27
tests/test_maven.py
Normal file
27
tests/test_maven.py
Normal file
@ -0,0 +1,27 @@
|
||||
import subprocess
|
||||
|
||||
import conftest
|
||||
|
||||
from nix_update.options import Options
|
||||
from nix_update.update import update
|
||||
|
||||
|
||||
def test_update(helpers: conftest.Helpers) -> None:
|
||||
with helpers.testpkgs() as path:
|
||||
opts = Options(attribute="maven", import_path=str(path))
|
||||
update(opts)
|
||||
version = subprocess.run(
|
||||
[
|
||||
"nix",
|
||||
"eval",
|
||||
"--raw",
|
||||
"--extra-experimental-features",
|
||||
"nix-command",
|
||||
"-f",
|
||||
path,
|
||||
"maven.version",
|
||||
],
|
||||
text=True,
|
||||
stdout=subprocess.PIPE,
|
||||
).stdout.strip()
|
||||
assert tuple(map(int, version.split("."))) > (3, 3, 0)
|
@ -13,4 +13,5 @@
|
||||
sourcehut = pkgs.python3.pkgs.callPackage ./sourcehut.nix { };
|
||||
savanna = pkgs.python3.pkgs.callPackage ./savanna.nix { };
|
||||
npm = pkgs.callPackage ./npm.nix { };
|
||||
maven = pkgs.callPackage ./maven.nix { };
|
||||
}
|
||||
|
16
tests/testpkgs/maven.nix
Normal file
16
tests/testpkgs/maven.nix
Normal file
@ -0,0 +1,16 @@
|
||||
{ maven, fetchFromGitHub }:
|
||||
|
||||
maven.buildMavenPackage rec {
|
||||
pname = "mariadb-connector-java";
|
||||
version = "3.3.0";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "mariadb-corporation";
|
||||
repo = "mariadb-connector-j";
|
||||
rev = "refs/tags/${version}";
|
||||
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
|
||||
};
|
||||
|
||||
mvnHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
|
||||
mvnParameters = "-DskipTests";
|
||||
}
|
Loading…
Reference in New Issue
Block a user