Skip to content

Commit 90992ea

Browse files
authored
Brings the Java build in line with other clients. (#2361)
Fixes several build issues that previously allowed improperly formatted files and files with incorrect copyright headers to pass CI. - Replaces the Java-specific copyright check with the standard pre-commit check. - Adds Java and Maven dependencies to the all configuration. - Moves formatting and Spotless checks into pre-commit. - Fixes formatting in files that were not properly formatted. - Removes the remaining headers_h_1 imports. Fixes #2131 Authors: - Igor Motov (https://github.com/imotov) Approvers: - Corey J. Nolet (https://github.com/cjnolet) - James Lamb (https://github.com/jameslamb) URL: #2361
1 parent 03fc8ca commit 90992ea

33 files changed

Lines changed: 132 additions & 113 deletions

‎.pre-commit-config.yaml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ repos:
9393
pass_filenames: false
9494
files: rust/.*
9595
language: rust
96+
- id: spotless-fmt
97+
name: spotless-fmt
98+
entry: ci/checks/run_spotless.sh
99+
pass_filenames: false
100+
files: ^java/cuvs-java/src/.*\.java$
101+
exclude: .*/panama/.*
102+
language: script
96103
- id: clang-format-with-cmake-placeholders
97104
name: clang-format-with-cmake-placeholders
98105
entry: python3 ci/checks/clang_format_with_cmake_placeholders.py

‎ci/checks/run_spotless.sh‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
# pre-commit hook wrapper that runs 'spotless:apply' to format the Java client sources.
6+
#
7+
# Most cuvs contributors do not work on the Java client and do not have Maven installed. For them
8+
# (running outside CI without Maven) this skips gracefully, so that 'pre-commit run --all-files'
9+
# does not require every contributor to install Maven. In CI, Maven is expected to be available and
10+
# its absence is treated as an error.
11+
12+
set -euo pipefail
13+
14+
if ! command -v mvn >/dev/null 2>&1; then
15+
if [ "${CI:-false}" = "true" ]; then
16+
echo "spotless-fmt: 'mvn' is required in CI but was not found on PATH." >&2
17+
exit 1
18+
fi
19+
echo "spotless-fmt: skipping Java formatting ('mvn' not installed and not running in CI)." >&2
20+
exit 0
21+
fi
22+
23+
exec mvn --batch-mode --quiet -f java/cuvs-java/pom.xml spotless:apply

‎conda/environments/all_cuda-129_arch-aarch64.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ dependencies:
3030
- libopenblas<=0.3.30
3131
- librmm==26.10.*,>=0.0.0a0
3232
- make
33+
- maven
3334
- nccl>=2.19
3435
- ninja
3536
- nodejs>=22
3637
- numpy>=2.0,<3.0
3738
- openblas
39+
- openjdk=22.*
3840
- pre-commit
3941
- pylibraft==26.10.*,>=0.0.0a0
4042
- pytest

‎conda/environments/all_cuda-129_arch-x86_64.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ dependencies:
2929
- libnvjitlink-dev
3030
- librmm==26.10.*,>=0.0.0a0
3131
- make
32+
- maven
3233
- nccl>=2.19
3334
- ninja
3435
- nodejs>=22
3536
- numpy>=2.0,<3.0
3637
- openblas
38+
- openjdk=22.*
3739
- pre-commit
3840
- pylibraft==26.10.*,>=0.0.0a0
3941
- pytest

‎conda/environments/all_cuda-133_arch-aarch64.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ dependencies:
3030
- libopenblas<=0.3.30
3131
- librmm==26.10.*,>=0.0.0a0
3232
- make
33+
- maven
3334
- nccl>=2.19
3435
- ninja
3536
- nodejs>=22
3637
- numpy>=2.0,<3.0
3738
- openblas
39+
- openjdk=22.*
3840
- pre-commit
3941
- pylibraft==26.10.*,>=0.0.0a0
4042
- pytest

‎conda/environments/all_cuda-133_arch-x86_64.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ dependencies:
2929
- libnvjitlink-dev
3030
- librmm==26.10.*,>=0.0.0a0
3131
- make
32+
- maven
3233
- nccl>=2.19
3334
- ninja
3435
- nodejs>=22
3536
- numpy>=2.0,<3.0
3637
- openblas
38+
- openjdk=22.*
3739
- pre-commit
3840
- pylibraft==26.10.*,>=0.0.0a0
3941
- pytest

‎dependencies.yaml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ dependencies:
297297
- output_types: [conda]
298298
packages:
299299
- c-compiler
300+
# spotless-fmt pre-commit hook requires Maven and a JDK
301+
- output_types: [conda]
302+
packages:
303+
- maven
304+
- &openjdk openjdk=22.*
300305
clang:
301306
common:
302307
- output_types: conda
@@ -591,7 +596,7 @@ dependencies:
591596
- *cmake_ver
592597
- libboost-devel
593598
- maven
594-
- openjdk=22.*
599+
- *openjdk
595600
bench:
596601
common:
597602
- output_types: [conda, pyproject, requirements]

‎java/cuvs-java/pom.xml‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,6 @@ SPDX-License-Identifier: Apache-2.0
252252
<groupId>com.diffplug.spotless</groupId>
253253
<artifactId>spotless-maven-plugin</artifactId>
254254
<version>2.44.5</version>
255-
<executions>
256-
<execution>
257-
<goals>
258-
<goal>apply</goal>
259-
</goals>
260-
<phase>validate</phase>
261-
</execution>
262-
</executions>
263255
<configuration>
264256
<java>
265257
<includes>
@@ -268,15 +260,21 @@ SPDX-License-Identifier: Apache-2.0
268260
<excludes>
269261
<exclude>src/**/panama/*.java</exclude>
270262
</excludes>
263+
<!--
264+
TODO: When we have more rules that should go to checkstyle or PMD
265+
(tracking issue: https://github.com/NVIDIA/cuvs/issues/2364)
266+
-->
267+
<replaceRegex>
268+
<name>Use the headers_h facade, not numbered jextract classes</name>
269+
<searchRegex>\bheaders_h_[0-9]+\b</searchRegex>
270+
<replacement>headers_h</replacement>
271+
</replaceRegex>
271272
<googleJavaFormat>
272273
<version>1.27.0</version>
273274
<style>GOOGLE</style>
274275
<reflowLongStrings>true</reflowLongStrings>
275276
<formatJavadoc>false</formatJavadoc>
276277
</googleJavaFormat>
277-
<licenseHeader>
278-
<file>${project.basedir}/../license-header.txt</file>
279-
</licenseHeader>
280278
</java>
281279
</configuration>
282280
</plugin>

‎java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSAceParams.java‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION.
2+
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55
package com.nvidia.cuvs;
@@ -75,8 +75,13 @@ public class CuVSAceParams {
7575
*/
7676
private final double maxGpuMemoryGb;
7777

78-
private CuVSAceParams(long npartitions, long efConstruction, String buildDir, boolean useDisk,
79-
double maxHostMemoryGb, double maxGpuMemoryGb) {
78+
private CuVSAceParams(
79+
long npartitions,
80+
long efConstruction,
81+
String buildDir,
82+
boolean useDisk,
83+
double maxHostMemoryGb,
84+
double maxGpuMemoryGb) {
8085
this.npartitions = npartitions;
8186
this.efConstruction = efConstruction;
8287
this.buildDir = buildDir;
@@ -259,8 +264,8 @@ public Builder withMaxGpuMemoryGb(double maxGpuMemoryGb) {
259264
* @return an instance of {@link CuVSAceParams}
260265
*/
261266
public CuVSAceParams build() {
262-
return new CuVSAceParams(npartitions, efConstruction, buildDir, useDisk,
263-
maxHostMemoryGb, maxGpuMemoryGb);
267+
return new CuVSAceParams(
268+
npartitions, efConstruction, buildDir, useDisk, maxHostMemoryGb, maxGpuMemoryGb);
264269
}
265270
}
266271
}

‎java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSResources.java‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,9 @@ static CuVSResources create(Path tempDirectory) throws Throwable {
122122
* @throws LibraryException if the native library cannot be loaded
123123
*/
124124
static CuVSResources create(
125-
Path tempDirectory,
126-
Path memoryTrackingCsvPath,
127-
Duration memoryTrackingSampleInterval) throws Throwable {
125+
Path tempDirectory, Path memoryTrackingCsvPath, Duration memoryTrackingSampleInterval)
126+
throws Throwable {
128127
return CuVSProvider.provider()
129-
.newCuVSResources(
130-
tempDirectory, memoryTrackingCsvPath, memoryTrackingSampleInterval);
128+
.newCuVSResources(tempDirectory, memoryTrackingCsvPath, memoryTrackingSampleInterval);
131129
}
132130
}

0 commit comments

Comments
 (0)