Skip to content

Commit 7f123dd

Browse files
committed
fix: add validation for using packages or lockFilePath, update MISSING_DEPENDENCY_CONFIGURATION_ERROR message
1 parent 9df0778 commit 7f123dd

File tree

2 files changed

+23
-6
lines changed
  • graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin
  • org.graalvm.python.embedding.tools/src/main/java/org/graalvm/python/embedding/tools/vfs

2 files changed

+23
-6
lines changed

graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/LockPackagesMojo.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class LockPackagesMojo extends AbstractGraalPyMojo {
8282
</configuration>
8383
</plugin>
8484
85-
Option 2: Use a pip-compatible requirements file:
85+
Option 2: Use a pip-compatible requirements.txt file:
8686
8787
<plugin>
8888
<groupId>org.graalvm.python</groupId>
@@ -93,12 +93,16 @@ public class LockPackagesMojo extends AbstractGraalPyMojo {
9393
</configuration>
9494
</plugin>
9595
96-
NOTE:
97-
• The <configuration> section must be declared on the graalpy-maven-plugin itself,
98-
not inside the process-graalpy-resources execution goal.
96+
IMPORTANT:
97+
• The requirementsFile workflow follows pip's native behavior.
98+
• GraalPy lock files are NOT used or generated when requirementsFile is specified.
99+
• The 'lock-packages' goal is NOT supported with <requirementsFile>.
100+
• Users are expected to manage locking / freezing themselves using pip conventions (e.g., pip freeze).
99101
• Do not define both <packages> and <requirementsFile> at the same time.
102+
• The <configuration> section must be declared on the graalpy-maven-plugin itself,
103+
not inside a specific execution.
100104
101-
For more information, please refer to:
105+
For more details, see:
102106
https://github.com/oracle/graalpython/blob/master/docs/user/Embedding-Build-Tools.md
103107
""";
104108

org.graalvm.python.embedding.tools/src/main/java/org/graalvm/python/embedding/tools/vfs/VFSUtils.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ static void installPackages(Path venvDirectory, List<String> packages, Path lock
578578
Objects.requireNonNull(packages);
579579
log.info("Using inline <packages> dependency mode.");
580580

581+
validatePackagesOrLockFile(packages, lockFilePath);
581582
logVenvArgs(venvDirectory, packages, lockFilePath, launcher, graalPyVersion, log);
582583

583584
List<String> pluginPackages = trim(packages);
@@ -683,7 +684,19 @@ public static void lockPackages(Path venvDirectory, List<String> packages, Path
683684
}
684685
}
685686

686-
private static void logVenvArgs(Path venvDirectory, List<String> packages, Path lockFile, Launcher launcherArgs,
687+
private static void validatePackagesOrLockFile(List<String> packages, Path lockFilePath) {
688+
boolean hasPackages = packages != null && !packages.isEmpty();
689+
boolean hasLockFile = lockFilePath != null;
690+
691+
if (hasPackages == hasLockFile) {
692+
throw new IllegalArgumentException(
693+
"Invalid configuration: <packages> and lock-file cannot be used together. Provide exactly one."
694+
);
695+
}
696+
}
697+
698+
699+
private static void logVenvArgs(Path venvDirectory, List<String> packages, Path lockFile, Launcher launcherArgs,
687700
String graalPyVersion, BuildToolLog log) throws IOException {
688701
if (log.isDebugEnabled()) {
689702
// avoid computing classpath if not necessary

0 commit comments

Comments
 (0)