eclipse-tycho / tycho

Tycho project repository (tycho)
https://tycho.eclipseprojects.io
Eclipse Public License 2.0
170 stars 189 forks source link

Control contents of generated pom.xml #3021

Closed tobias-hammerschmidt closed 11 months ago

tobias-hammerschmidt commented 11 months ago

We're using tycho 4.0.3 with pomless build for our rcp apps. Now we're facing an issue regarding the generated pom.xml files which end up in the artifacts generated by tycho (in META-INF\maven\groupId\artifactId\pom.xml. With tycho 2.6 the contents looked like this:

<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">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.company</groupId>
    <artifactId>com.company.app.application.splash</artifactId>
    <version>1.0.0</version>
    <packaging>eclipse-plugin</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-maven-plugin</artifactId>
                <version>2.6.0</version>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </build>
</project>

After updating to tycho 4.0.3 the content now looks like this:

<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">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.company</groupId>
    <artifactId>com.company.app.application.splash</artifactId>
    <version>1.0.0</version>
    <dependencies>
        <dependency>
            <groupId>com.company</groupId>
            <artifactId>com.company.app.application</artifactId>
            <version>1.0.0</version>
            <scope>compile</scope>
            <optional>false</optional>
        </dependency>
    </dependencies>
</project>

In this example com.company.app.application.splash is a fragment bundle with the host com.company.app.application. Now in case we create a bugfix for the host bundle and updating its version to 1.0.1 this is also reflected in the generated pom of the fragment resulting in

<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">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.company</groupId>
    <artifactId>com.company.app.application.splash</artifactId>
    <version>1.0.0</version>
    <dependencies>
        <dependency>
            <groupId>com.company</groupId>
            <artifactId>com.company.app.application</artifactId>
            <version>1.0.1</version>
            <scope>compile</scope>
            <optional>false</optional>
        </dependency>
    </dependencies>
</project>

This is problematic for us since we're using a binary comparison of the generated bundles which is failing just because of the changed generated pom.xml. Is there any option to control the contents of the generated pom.xml especially suppressing certain contents? Note that we are not using tycho baseline compare and also don't want to. Our approach has served us well so far but now breaks due to the behavior change in tycho. Also if the minimum version of the required host bundle is not changed in the fragment why does tycho still enforce the bugfix version?

tobias-hammerschmidt commented 11 months ago

Ok guess I can use skipPomGeneration as noted here: https://github.com/eclipse-tycho/tycho/discussions/1573#discussioncomment-3931417

tobias-hammerschmidt commented 11 months ago

With skipPomGeneration the generated pom.xml now looks like this:

<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">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.company</groupId>
    <artifactId>com.company.app.application.splash</artifactId>
    <version>1.0.0</version>
    <packaging>eclipse-plugin</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-maven-plugin</artifactId>
                <version>4.0.3</version>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </build>
</project>

It's an improvement but still will break once we update the tycho version. According to the documentation in https://tycho.eclipseprojects.io/doc/3.0.0/tycho-packaging-plugin/update-consumer-pom-mojo.html#tycho-packaging-update-consumer-pom it should be possible to tweak this pom using flatten-maven-plugin.

tobias-hammerschmidt commented 11 months ago

Ok so the resulting generated pom.xml can be tweaked with the flatten-maven-plugin but its important to bind the flatten goal to the correct lifecycle phase (prepare-package).