apache / apache/maven

[MNG-7815] need for finer-grained base final name property in super POM

Open
#9,104 0 comments 0 reactions 0 assignees View on GitHub
enhancement priority:minor
Dominant language
Java
Stars
5.3k
Forks
3.1k
Avg merge
20h 42m
Merged PRs (30d)
297

Description

**[Garret Wilson](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=garretwilson)** opened **[MNG-7815](https://issues.apache.org/jira/browse/MNG-7815?redirect=false)** and commented

Maven's [super POM](https://maven.apache.org/ref/3.9.2/maven-model-builder/super-pom.html) defines `build.finalName` like this:

```xml


${project.artifactId}-${project.version}
```

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:

```xml


foo-bar-${project.artifactId}-${project.version}
```

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:

```xml

foo-bar-${project.artifactId}:${project.version}
```

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:

```xml


${project.artifactId}
${finalBaseName}-${project.version}
```

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:

```xml


foo-bar-${project.artifactId}
```

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

```xml

${build.finalBaseName}:${project.version}
```

In my own parent POM used across many projects, I'm alrady integrating this feature myself as part of [JAVA-308](https://globalmentor.atlassian.net/browse/JAVA-308).

```xml

${project.artifactId}



${build.finalBaseName}-${project.version}
```

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

---
No further details from [MNG-7815](https://issues.apache.org/jira/browse/MNG-7815?redirect=false)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.