Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Maven multi-module projects #1441

Open
cowwoc opened this issue Oct 24, 2024 · 1 comment
Open

Add support for Maven multi-module projects #1441

cowwoc opened this issue Oct 24, 2024 · 1 comment
Labels
kind/enhancement Improvements or new features

Comments

@cowwoc
Copy link

cowwoc commented Oct 24, 2024

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).

@cowwoc cowwoc added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Oct 24, 2024
@justinvp justinvp added kind/enhancement Improvements or new features and removed needs-triage Needs attention from the triage team kind/bug Some behavior is incorrect or out of spec labels Nov 1, 2024
@justinvp justinvp changed the title Unable to use pulumi in a Maven multi-module project Add support for Maven multi-module projects Nov 1, 2024
@justinvp
Copy link
Member

justinvp commented Nov 1, 2024

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:

func (gradle) findGradleRoot(workdir fsys.ParentFS) (fsys.ParentFS, string, error) {
gradleRootMarkers := []string{
"settings.gradle",
"settings.gradle.kts",
}
d := workdir
subproject := ""
for {
for _, p := range gradleRootMarkers {
isGradleRoot, err := fsys.FileExists(d, p)
if err != nil {
return nil, subproject, err
}
if isGradleRoot {
return d, subproject, nil
}
}
if !d.HasParent() {
// Abort search and assume workdir is the root
return workdir, subproject, nil
}
subproject = fmt.Sprintf(":%s%s", d.Base(), subproject)
d = d.Parent()
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

2 participants