Skip to content

Commit

Permalink
Merge staging-next into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Nov 27, 2024
2 parents 2503bd9 + f56c2b7 commit 8cfd862
Show file tree
Hide file tree
Showing 53 changed files with 1,121 additions and 899 deletions.
84 changes: 84 additions & 0 deletions doc/languages-frameworks/maven.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,90 @@ This package calls `maven.buildMavenPackage` to do its work. The primary differe
After setting `maven.buildMavenPackage`, we then do standard Java `.jar` installation by saving the `.jar` to `$out/share/java` and then making a wrapper which allows executing that file; see [](#sec-language-java) for additional generic information about packaging Java applications.
:::

### Overriding Maven package attributes {#maven-overriding-package-attributes}

```
overrideMavenAttrs :: (AttrSet -> Derivation) | ((AttrSet -> Attrset) -> Derivation) -> Derivation
```

The output of `buildMavenPackage` has an `overrideMavenAttrs` attribute, which is a function that takes either
- any subset of the attributes that can be passed to `buildMavenPackage`

or
- a function that takes the argument passed to the previous invocation of `buildMavenPackage` (conventionally called `old`) and returns an attribute set that can be passed to `buildMavenPackage`

and returns a derivation that builds a Maven package based on the old and new arguments merged.

This is similar to [](#sec-pkg-overrideAttrs), but notably does not allow accessing the final value of the argument to `buildMavenPackage`.

:::{.example}
### `overrideMavenAttrs` Example

Use `overrideMavenAttrs` to build `jd-cli` version 1.2.0 and disable some flaky test:

```nix
jd-cli.overrideMavenAttrs (old: rec {
version = "1.2.0";
src = fetchFromGitHub {
owner = old.src.owner;
repo = old.src.repo;
rev = "${old.pname}-${version}";
# old source hash of 1.2.0 version
hash = "sha256-US7j6tQ6mh1libeHnQdFxPGoxHzbZHqehWSgCYynKx8=";
};
# tests can be disabled by prefixing it with `!`
# see Maven documentation for more details:
# https://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html#Multiple_Formats_in_One
mvnParameters = lib.escapeShellArgs [
"-Dsurefire.failIfNoSpecifiedTests=false"
"-Dtest=!JavaDecompilerTest#basicTest,!JavaDecompilerTest#patternMatchingTest"
];
# old mvnHash of 1.2.0 maven dependencies
mvnHash = "sha256-N9XC1pg6Y4sUiBWIQUf16QSXCuiAPpXEHGlgApviF4I=";
});
```
:::

### Offline build {#maven-offline-build}

By default, `buildMavenPackage` does the following:

1. Run `mvn package -Dmaven.repo.local=$out/.m2 ${mvnParameters}` in the
`fetchedMavenDeps` [fixed-output derivation](https://nixos.org/manual/nix/stable/glossary.html#gloss-fixed-output-derivation).
2. Run `mvn package -o -nsu "-Dmaven.repo.local=$mvnDeps/.m2"
${mvnParameters}` again in the main derivation.

As a result, tests are run twice.
This also means that a failing test will trigger a new attempt to realise the fixed-output derivation, which in turn downloads all dependencies again.
For bigger Maven projects, this might lead to a long feedback cycle.

Use `buildOffline = true` to change the behaviour of `buildMavenPackage to the following:
1. Run `mvn de.qaware.maven:go-offline-maven-plugin:1.2.8:resolve-dependencies
-Dmaven.repo.local=$out/.m2 ${mvnDepsParameters}` in the fixed-output derivation.
2. Run `mvn package -o -nsu "-Dmaven.repo.local=$mvnDeps/.m2"
${mvnParameters}` in the main derivation.

As a result, all dependencies are downloaded in step 1 and the tests are executed in step 2.
A failing test only triggers a rebuild of step 2 as it can reuse the dependencies of step 1 because they have not changed.

::: {.warning}
Test dependencies are not downloaded in step 1 and are therefore missing in
step 2 which will most probably fail the build. The `go-offline` plugin cannot
handle these so-called [dynamic dependencies](https://github.com/qaware/go-offline-maven-plugin?tab=readme-ov-file#dynamic-dependencies).
In that case you must add these dynamic dependencies manually with:
```nix
maven.buildMavenPackage rec {
manualMvnArtifacts = [
# add dynamic test dependencies here
"org.apache.maven.surefire:surefire-junit-platform:3.1.2"
"org.junit.platform:junit-platform-launcher:1.10.0"
];
};
```
:::

### Stable Maven plugins {#stable-maven-plugins}

Maven defines default versions for its core plugins, e.g. `maven-compiler-plugin`. If your project does not override these versions, an upgrade of Maven will change the version of the used plugins, and therefore the derivation and hash.
Expand Down
6 changes: 6 additions & 0 deletions doc/redirects.json
Original file line number Diff line number Diff line change
Expand Up @@ -3190,6 +3190,12 @@
"maven-buildmavenpackage": [
"index.html#maven-buildmavenpackage"
],
"maven-overriding-package-attributes": [
"index.html#maven-overriding-package-attributes"
],
"maven-offline-build": [
"index.html#maven-offline-build"
],
"stable-maven-plugins": [
"index.html#stable-maven-plugins"
],
Expand Down
32 changes: 16 additions & 16 deletions pkgs/applications/editors/jetbrains/bin/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"clion": {
"update-channel": "CLion RELEASE",
"url-template": "https://download.jetbrains.com/cpp/CLion-{version}.tar.gz",
"version": "2024.2.3",
"sha256": "0afb6e32fe1ceb77ddd07ca7fa7d01a0a5e73a0df42ec58183f9c1a06b84446e",
"url": "https://download.jetbrains.com/cpp/CLion-2024.2.3.tar.gz",
"build_number": "242.23726.125"
"version": "2024.3",
"sha256": "e66ee52c365552fe40d035f5b205ab8c28a9a02ed4af5f787b78a0048bcf7f81",
"url": "https://download.jetbrains.com/cpp/CLion-2024.3.tar.gz",
"build_number": "243.21565.238"
},
"datagrip": {
"update-channel": "DataGrip RELEASE",
Expand Down Expand Up @@ -150,10 +150,10 @@
"clion": {
"update-channel": "CLion RELEASE",
"url-template": "https://download.jetbrains.com/cpp/CLion-{version}-aarch64.tar.gz",
"version": "2024.2.3",
"sha256": "be3e6f0d490517c8f6e7c7ac248ab8e8823bf19c8102e7695725f80df6c11d63",
"url": "https://download.jetbrains.com/cpp/CLion-2024.2.3-aarch64.tar.gz",
"build_number": "242.23726.125"
"version": "2024.3",
"sha256": "526147203ce3f9ec25e264f33fca042fda59a728237a165983c47c0c06356f6e",
"url": "https://download.jetbrains.com/cpp/CLion-2024.3-aarch64.tar.gz",
"build_number": "243.21565.238"
},
"datagrip": {
"update-channel": "DataGrip RELEASE",
Expand Down Expand Up @@ -289,10 +289,10 @@
"clion": {
"update-channel": "CLion RELEASE",
"url-template": "https://download.jetbrains.com/cpp/CLion-{version}.dmg",
"version": "2024.2.3",
"sha256": "0dfc4d50268e58bb6b3c42c270ea8cca638a8733a5e2e010447cc74d585895e8",
"url": "https://download.jetbrains.com/cpp/CLion-2024.2.3.dmg",
"build_number": "242.23726.125"
"version": "2024.3",
"sha256": "e3d82ad3303cb4f373efce378f7f289afd3b35d3315d03ac53dc27302c87aa6f",
"url": "https://download.jetbrains.com/cpp/CLion-2024.3.dmg",
"build_number": "243.21565.238"
},
"datagrip": {
"update-channel": "DataGrip RELEASE",
Expand Down Expand Up @@ -428,10 +428,10 @@
"clion": {
"update-channel": "CLion RELEASE",
"url-template": "https://download.jetbrains.com/cpp/CLion-{version}-aarch64.dmg",
"version": "2024.2.3",
"sha256": "998d629381e6f596b8e0cf5289fe8ca7cfd3221fc73b6c8548d768889b14196f",
"url": "https://download.jetbrains.com/cpp/CLion-2024.2.3-aarch64.dmg",
"build_number": "242.23726.125"
"version": "2024.3",
"sha256": "2f4ad6ea4ffb0862f85780cd960b46925ea6c9e5f97e9fa290f3007652103825",
"url": "https://download.jetbrains.com/cpp/CLion-2024.3-aarch64.dmg",
"build_number": "243.21565.238"
},
"datagrip": {
"update-channel": "DataGrip RELEASE",
Expand Down
3 changes: 2 additions & 1 deletion pkgs/applications/editors/jetbrains/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ in
, python3
, lldb
, dotnet-sdk_7
, dotnet-sdk_8
, maven
, openssl
, expat
Expand Down Expand Up @@ -126,7 +127,7 @@ rec {
for dir in plugins/clion-radler/DotFiles/linux-*; do
rm -rf $dir/dotnet
ln -s ${dotnet-sdk_7} $dir/dotnet
ln -s ${dotnet-sdk_8.unwrapped}/share/dotnet $dir/dotnet
done
)
'';
Expand Down
Loading

0 comments on commit 8cfd862

Please sign in to comment.