Maven with an explicit finalName won't work properly

前端 未结 5 612
说谎
说谎 2021-01-17 10:46

1. Background

My maven project has a lot of modules and submodules with jars and wars and everything works. I also can dep

5条回答
  •  孤街浪徒
    2021-01-17 11:25

    Interesting! I started off cloning the repo and reproducing the error. I would appreciate any leads that can be taken from any of the steps mentioned below that helped me debug the problem -

    1. Maven Life Cycle Phases The phase where the issue occurred was the package phase of the lifecycle. Meaning mvn package reproduces the issue with your project.

    2. Went through the stack trace lines in the error. Getting to know its the expression evaluation where it's failing -

      @Override
      public Object evaluate( String expr ) throws ExpressionEvaluationException {
          return evaluate( expr, null ); // Line 143
      }
      
    3. It's also not the finalName attribute which was causing it. Since specifying the default value of the same ${artifactId}-${version} works fine with the same project configs.

    4. Then tried changing the packaging of the any-submodule as

      pom
      

      and the error went away. Meaning while packaging as jar , war etc the expression evaluation is different and results in an overflow.

    5. Modifying the any-module or the any-submodule pom.xml content I can say with some confidence that it's the project.parent.name that is causing a recursion in evaluating the expression and causing the stack overflow(How? - is something I am still looking for..). Also, changing

      ${project.parent.name}-${project.artifactId}

      to

      ${parent.name}-${project.artifactId}

      works for me in the sense that I do not get an error but the jar generated is of type -

      ${parent.name}-any-module-any-submodule-1.0-SNAPSHOT.jar and

      ${parent.name}-any-submodule-1.0-SNAPSHOT respectively with the change.

    6. Looking for the solution according to the requirement, I am seeking a tail to the recursion that you are using.

    Note - Still working on finding an appropriate solution to this problem.

提交回复
热议问题