Skip to content

Commit 0846a02

Browse files
committed
fix(maven): validate lock file usage when no packages or requirements.txt are configured
1 parent 850a56e commit 0846a02

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
*/
4141
package org.graalvm.python.maven.plugin;
4242

43+
import java.nio.file.Files;
4344
import org.apache.maven.plugin.MojoExecutionException;
4445
import org.apache.maven.plugins.annotations.LifecyclePhase;
4546
import org.apache.maven.plugins.annotations.Mojo;
@@ -100,7 +101,16 @@ private void manageVenv() throws MojoExecutionException {
100101
MavenDelegateLog log = new MavenDelegateLog(getLog());
101102
Path lockFile = getLockFile();
102103
Path reqFile = resolveReqFile();
103-
if ((packages == null || packages.isEmpty()) && reqFile == null) {
104+
105+
boolean emptyPackages = packages == null || packages.isEmpty();
106+
boolean hasReqFile = reqFile != null && Files.exists(reqFile);
107+
boolean hasLockFile = lockFile != null && Files.exists(lockFile);
108+
109+
if (emptyPackages && !hasReqFile) {
110+
if (hasLockFile) {
111+
throw new MojoExecutionException(
112+
"Lock file is present, but no Python packages or requirements.txt are configured.");
113+
}
104114
return;
105115
}
106116
try {

0 commit comments

Comments
 (0)