Skip to content

complex profile behaviour #316

@delanym

Description

@delanym

In my project snapshot/release repositories are configured
in a parent pom
in 2 mutually exclusive profiles
activated by the presence or absence of a property.

Its the same repos in each profile, but with different update intervals.
Flatten mode "defaults" runs in phase "initialize".

I found that my repositories tag was not included in the flattened pom.
Then I saw https://www.mojohaus.org/flatten-maven-plugin/flatten-mojo.html
that profiles are not resolved, but should be included in the flattened pom. But there are no profiles in the flatten pom either.

So I made this test project

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <version>${revision}${changelist}</version>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>

  <profiles>
    <profile>
      <id>repo</id>
      <activation>
        <property>
          <name>changelist</name>
        </property>
      </activation>
      <repositories>
        <repository>
          <id>repo.jenkins-ci.org</id>
          <url>https://repo.jenkins-ci.org/public/</url>
        </repository>
      </repositories>
    </profile>
  </profiles>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>flatten-maven-plugin</artifactId>
        <version>1.3.0</version>
        <configuration>
          <updatePomFile>true</updatePomFile>
          <flattenMode>defaults</flattenMode>
          <flattenDependencyMode>direct</flattenDependencyMode>
        </configuration>
        <executions>
          <execution>
            <id>flatten</id>
            <goals>
              <goal>flatten</goal>
            </goals>
            <phase>initialize</phase>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

mvn initialize -Drevision=2.4.2 -Dchangelist=-SNAPSHOT && cat .flattened-pom.xml

I see my profiles are added. I was expecting "only the Activation and the Dependency dependencies of a Profile are copied to the flattened POM" but here I see the repositories.

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <version>2.4.2-SNAPSHOT</version>
  <profiles>
    <profile>
      <id>repo</id>
      <activation>
        <property>
          <name>changelist</name>
        </property>
      </activation>
      <repositories>
        <repository>
          <id>repo.jenkins-ci.org</id>
          <url>https://repo.jenkins-ci.org/public/</url>
        </repository>
      </repositories>
    </profile>
  </profiles>
</project>

I gave up on configuring repositories in profiles.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions