Uploaded image for project: 'Maven Wrapper'
  1. Maven Wrapper
  2. MWRAPPER-83

mvnw fails in zsh due to empty MAVEN_OPTS variable

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Invalid
    • 3.1.1
    • None
    • Maven Wrapper Scripts
    • None

    Description

      Running mvnw in zsh, I get:

      Error: Could not find or load main class
      Caused by: java.lang.ClassNotFoundException:

      Recreate Instructions

      1. docker run -it ubuntu:focal-20221019   # next instructions are within Docker container
      2.  apt update; apt install default-jdk maven zsh -y        # still have to interactively make a location selection
      3.  export JAVA_HOME=/usr
      4. mvn -B archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-simple -DarchetypeVersion=1.4 -DgroupId=demo -DartifactId=app -Dversion=1.0
      5. cd app
      6. mvn org.apache.maven.plugins:maven-wrapper-plugin:3.1.1:wrapper
      7. bash mvnw validate   # good, works
      8. zsh mvnw validate     # bad, recreates problem

       

      Thoughts{}

      The problem centers around the different behavior of bash, zsh (at least with the versions in this recreate) in interpreting the expansion of the "empty" MAVEN_OPTS variable.  With bash this gets resolved to nothing whereas in zsh this is resolved to a ' ' string, which the java executable seems to treat as the main class argument, and thus fails.

      Maybe someone more familiar with shell options knows a workaround, but given this seems to happen with the default options in the above environment, it seems worth addressing in the script.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              scottkurz Scott Kurz
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: