maven-site icon indicating copy to clipboard operation
maven-site copied to clipboard

[MNGSITE-515] Profiles not properly specified

Open jira-importer opened this issue 2 years ago • 3 comments

Philippe Cloutier opened MNGSITE-515 and commented

I don't know if an unspecified feature is considered a bug or merely as an issue, but here goes anyway...

The POM Reference does not specify profiles beyond the following:


Profiles

A new feature of the POM 4.0 is the ability of a project to change settings depending on the environment where it is being built. A profile element contains both an optional activation (a profile trigger) and the set of changes to be made to the POM if that profile has been activated. For example, a project built for a test environment may point to a different database than that of the final deployment. Or dependencies may be pulled from different repositories based upon the JDK version used. The elements of profiles are as follows:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
 ...

<profiles>
    <profile>
      <id>test</id>
      <activation>...</activation>
      <build>...</build>
      <modules>...</modules>
      <repositories>...</repositories>
      <pluginRepositories>...</pluginRepositories>
      <dependencies>...</dependencies>
      <reporting>...</reporting>
      <dependencyManagement>...</dependencyManagement>
      <distributionManagement>...</distributionManagement>
    </profile>
  </profiles>
</project>

...and the following section about activation.

Several sources including the following indicate that a profile element can also contain a properties element:

  • https://www.baeldung.com/maven-profiles
  • https://stackoverflow.com/questions/35468752/maven-profiles-with-variable-for-properties
  • https://mkyong.com/maven/maven-profiles-example/

This also seems to contradict the Profiles in POMs section of Introduction to Build Profiles, although I for one struggle to make sense of:

<properties> (flag)(not actually available in the main POM, but used behind the scenes)(flag)


By the way, since profiles can be activated explicitly, the beginning of the Activation subsection is misleading:

The power of a profile comes from its ability to modify the basic POM only under certain circumstances. Those circumstances are specified via an activation element.


No further details from MNGSITE-515

jira-importer avatar Mar 06 '23 23:03 jira-importer

I am the reporter of this issue, but cannot edit the report. @jira-importer did not properly format the quoted part, and I cannot fix that.

This report (including all messages and attachments I add to it) is offered under the terms of CC0 1.0.

Chealer avatar Jul 15 '25 14:07 Chealer

Hi @Chealer I was pondering some time about your issue and the only clear thing I saw was the missing note about <properties> (see #1490 ). But the title of your issues makes me think that you for you there is more you think is "not properly specified". Can you point out what else you have issues to understand? Thank you

Bukama avatar Dec 15 '25 18:12 Bukama

Greetings @Bukama,

Hi @Chealer I was pondering some time about your issue and the only clear thing I saw was the missing note about <properties> (see #1490 ). But the title of your issues makes me think that you for you there is more you think is "not properly specified".

Indeed

Can you point out what else you have issues to understand?

I reported this more than 2 years ago and have not worked on any project using Maven for more than 1 year, so I forgot what exactly I had noticed, but I see in the current documentation that it is neither clear what is a valid profile, nor what a profile's effect is when it is activated.

The POM Reference contains:

The elements of profiles are as follows:

<project xmlns="http://maven.apache.org/POM/4.0.0">
  ...
  <profiles>
    <profile>
      <id>test</id>
      <activation>...</activation>
      <build>...</build>
      <modules>...</modules>
      <repositories>...</repositories>
      <pluginRepositories>...</pluginRepositories>
      <dependencies>...</dependencies>
      <reporting>...</reporting>
      <dependencyManagement>...</dependencyManagement>
      <distributionManagement>...</distributionManagement>
    </profile>
  </profiles>
</project>

... yet the above sources provide examples of profiles which do not have all these elements.

Also, Profiles in POMs says POM profiles can modify "a subset of the <build> element", so presumably profiles with some <build> elements are invalid.

As for the effect, the reference should specify what the effect of an activated profile with a <dependencyManagement> element (for example) is.

As things stand, some information which defines how profiles behave is only found in Introduction to Build Profiles.

Thank you

Thanks to you

Chealer avatar Dec 17 '25 18:12 Chealer

Sorry for the delayed answer (stressful work, xmas and so on...)

Thank you for your feedback (esp. after such a long time). I decided to merge the parts of the POM reference into the guide and update it with more clearer wording and some new examples.

Bukama avatar Dec 26 '25 18:12 Bukama

Not at all

My pleasure, thanks to you

Chealer avatar Dec 27 '25 11:12 Chealer