Sitelet https://github.com/openrewrite/rewrite-maven-plugin/issues/1097
Skip to content

Profiles in child POMs are not considered active #1097

Description

@shanman190

What version of OpenRewrite are you using?

I am using main (dc8f996)

  • OpenRewrite v8.72.0-SNAPSHOT
  • Maven plugin v6.28.0-SNAPSHOT

How are you running OpenRewrite?

I am using the Maven plugin, and my project is a multi module project.

/pom.xml

<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.example</groupId>
    <artifactId>parent</artifactId>
    <version>1.0.0</version>
    <packaging>pom</packaging>

    <modules>
        <module>app</module>
    </modules>
</project>

/app/pom.xml

<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.example</groupId>
    <artifactId>app</artifactId>
    <version>1.0.0</version>

    <parent>
        <groupId>com.example</groupId>
        <artifactId>parent</artifactId>
        <version>1.0.0</version>
    </parent>
    <profiles>
        <profile>
            <id>Local</id>
            <activation>
                <file>
                    <exists>${basedir}/pom.xml</exists>
                </file>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-core</artifactId>
                    <version>2.20.1</version>
                </dependency>
            </dependencies>
        </profile>
    </profiles>
</project>

Problem

When running dependency related recipes, you'll observe using the example project that jackson-core in this context will not appear as a dependency. In cases all other conditional profile cases, the same can be observed as well. Furthermore, you can observe that no activeProfiles are noted within the MavenResolutionResult attached to the /app/pom.xml document either.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions