complex profile behaviour
delanym opened this issue · comments
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.