Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-7815

need for finer-grained base final name property in super POM

Attach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • POM
    • None

    Description

      Maven's super POM defines build.finalName like this:

        <build><finalName>${project.artifactId}-${project.version}</finalName>
      

      With no changes that produces artifacts like the following for the project web-app:

      • web-app-1.2.3.jar
      • web-app-1.2.3-javadoc.jar
      • web-app-1.2.3-sources.jar

      Those defaults are fine used locally, or with the entire com.example:web-app:1.2.3 coordinates. But let's say that I'm going to upload those JARs somewhere where I want them to have a unique names across projects to be stored in the same directory. (AWS Lambda comes to mind.) I want to produce artifacts like foo-bar-web-app-1.2.3.jar. To do that I need to override build.finalName in my POM like this:

        <build><finalName>foo-bar-${project.artifactId}-${project.version}</finalName>
      

      I shouldn't need to redefine the entire filename. I'm just wanting to change the base name—the part that comes before the version. But it gets more interesting because I want my Maven build to also produce a Docker image, and I need to somehow split out the "base name" and the "version" separately. Using io.fabric8:docker-maven-plugin I'd do something like this:

      <image>
        <name>foo-bar-${project.artifactId}:${project.version}</name>
      

      I shouldn't have to duplicate the base name.

      What I really need is a build.finalBaseName property. This would be extremely simple to add to the Maven super POM in a 100% transparently backwards compatible manner. Here is all you need in the super POM:

        <build><finalBaseName>${project.artifactId}</finalBaseName>
          <finalName>${finalBaseName}-${project.version}</finalName>
      

      With no changes, all the thousands of Maven POMs work exactly as they did before. But if I want to change the base name from web-app to foo-bar-web-app, I simply do this:

        <build><finalBaseName>foo-bar-${project.artifactId}</finalBaseName>
      

      Even better, I don't have to duplicate the base name. Here is what I would use to set the Docker image information:

      <image>
        <name>${build.finalBaseName}:${project.version}</name>
      

      In my own parent POM used across many projects, I'm alrady integrating this feature myself as part of JAVA-308.

        <properties>
          <build.finalBaseName>${project.artifactId}</build.finalBaseName><build>
          <finalName>${build.finalBaseName}-${project.version}</finalName>
      

      Still it would be very nice to have this fine-grained property available automatically with Maven out of the box.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            garretwilson Garret Wilson

            Dates

              Created:
              Updated:

              Slack

                Issue deployment