|
66 | 66 | import org.graalvm.python.embedding.tools.exec.GraalPyRunner;
|
67 | 67 | import org.graalvm.python.embedding.tools.vfs.VFSUtils;
|
68 | 68 |
|
69 |
| - |
70 | 69 | import static org.graalvm.python.embedding.tools.vfs.VFSUtils.VFS_HOME;
|
71 | 70 | import static org.graalvm.python.embedding.tools.vfs.VFSUtils.VFS_ROOT;
|
72 | 71 | import static org.graalvm.python.embedding.tools.vfs.VFSUtils.VFS_VENV;
|
@@ -483,7 +482,21 @@ private void runGraalPy(MavenProject project, Log log, String... args) throws Mo
|
483 | 482 | }
|
484 | 483 |
|
485 | 484 | private static String getGraalPyVersion(MavenProject project) throws MojoExecutionException {
|
486 |
| - return getGraalPyArtifact(project).getVersion(); |
| 485 | + DefaultArtifact a = (DefaultArtifact) getGraalPyArtifact(project); |
| 486 | + String version = a.getVersion(); |
| 487 | + if(a.isSnapshot()) { |
| 488 | + // getVersion for a snapshot artefact returns base version + timestamp - e.g. 24.2.0-20240808.200816-1 |
| 489 | + // and there might be snapshot artefacts with different timestamps in the repository. |
| 490 | + // We should use $baseVersion + "-SNAPSHOT" as maven is in such case |
| 491 | + // able to properly resolve all project artefacts. |
| 492 | + version = a.getBaseVersion(); |
| 493 | + if(!version.endsWith("-SNAPSHOT")) { |
| 494 | + // getBaseVersion is expected to return a version without any additional metadata, e.g. 24.2.0-20240808.200816-1 -> 24.2.0, |
| 495 | + // but also saw getBaseVersion() already returning version with -SNAPSHOT suffix |
| 496 | + version = version + "-SNAPSHOT"; |
| 497 | + } |
| 498 | + } |
| 499 | + return version; |
487 | 500 | }
|
488 | 501 |
|
489 | 502 | private static Artifact getGraalPyArtifact(MavenProject project) throws MojoExecutionException {
|
@@ -514,9 +527,10 @@ private Set<String> calculateLauncherClasspath(MavenProject project) throws Mojo
|
514 | 527 |
|
515 | 528 | // 1.) python-launcher and transitive dependencies
|
516 | 529 | // get the artifact from its direct dependency in graalpy-maven-plugin
|
| 530 | + getLog().debug("calculateLauncherClasspath based on " + GRAALPY_GROUP_ID + ":" + GRAALPY_MAVEN_PLUGIN_ARTIFACT_ID + ":" + version); |
517 | 531 | DefaultArtifact mvnPlugin = new DefaultArtifact(GRAALPY_GROUP_ID, GRAALPY_MAVEN_PLUGIN_ARTIFACT_ID, version, "compile", "jar", null, new DefaultArtifactHandler("pom"));
|
518 | 532 | ProjectBuildingResult result = buildProjectFromArtifact(mvnPlugin);
|
519 |
| - Artifact graalPyLauncherArtifact = result.getProject().getArtifacts().stream().filter(a ->GRAALPY_GROUP_ID.equals(a.getGroupId()) && PYTHON_LAUNCHER_ARTIFACT_ID.equals(a.getArtifactId()) && version.equals(a.getVersion())) |
| 533 | + Artifact graalPyLauncherArtifact = result.getProject().getArtifacts().stream().filter(a ->GRAALPY_GROUP_ID.equals(a.getGroupId()) && PYTHON_LAUNCHER_ARTIFACT_ID.equals(a.getArtifactId())) |
520 | 534 | .findFirst()
|
521 | 535 | .orElse(null);
|
522 | 536 | // python-launcher artifact
|
|
0 commit comments