pulumi / pulumi-java

Java support for Pulumi
Apache License 2.0
69 stars 21 forks source link

Add support for Maven multi-module projects #1441

Open cowwoc opened 1 week ago

cowwoc commented 1 week ago

What happened?

error: failed to discover plugin requirements: language host could not determine Pulumi packages: could not find ./mvnw, mvn on the $PATH: exec: "mvn": executable file not found in %PATH%

Example

  1. Create a multi-module Maven project containing mvnw in the root
  2. Place the pulumi-java project in a sub-module
  3. Run pulumi up
  4. Pulumi will complain:

error: failed to discover plugin requirements: language host could not determine Pulumi packages: could not find ./mvnw, mvn on the $PATH: exec: "mvn": executable file not found in %PATH%

Creating symbol links from the mvnw installation in the root module does not help (I get the same error). If I copy the files over, the error goes away, but obviously it's bad to maintain copies as they will fall out-of-sync.

Ideally, pulumi should scan the ancestor directories one at a time looking for mvnw and use the existing installation without needing a local copy or symbol link.

Output of pulumi about

CLI
Version      3.137.0
Go Version   go1.23.2
Go Compiler  gc

Host
OS       Microsoft Windows 10 Pro
Version  10.0.19045 Build 19045
Arch     x86_64

This project is written in java: executable='C:\Users\Gili\scoop\apps\openjdk\current\bin\java.exe' version='openjdk 23.0.1 2024-10-15
OpenJDK Runtime Environment (build 23.0.1+11-39)
OpenJDK 64-Bit Server VM (build 23.0.1+11-39, mixed mode, sharing)' java='C:\Users\Gili\scoop\apps\openjdk\current\bin\java.exe' javac='23.0.1'

Backend
Name           pulumi.com
URL            https://app.pulumi.com/cowwoc
User           cowwoc
Organizations  cowwoc, licensed-app
Token type     personal

No dependencies found

Pulumi locates its logs in C:\Users\Gili\AppData\Local\Temp by default
warning: Failed to get information about the plugin: failed to discover plugin requirements: language host could not determine Pulumi packages: could not find ./mvnw, mvn on the $PATH: exec: "mvn": executable file not found in %!P(MISSING)ATH%!(NOVERB)
warning: Failed to get information about the current stack: No current stack

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

justinvp commented 4 days ago

Ideally, pulumi should scan the ancestor directories one at a time looking for mvnw and use the existing installation without needing a local copy or symbol link.

Agreed. Something along the lines of what we do for Gradle:

https://github.com/pulumi/pulumi-java/blob/a34adb2d625c1fa5c3ebc03a0bf5c61014a6152b/pkg/internal/executors/executor_gradle.go#L58-L82