Custom pom.xml filename in Maven multimodule for Tycho
Asked Answered
R

2

6

I have a project with a couple of dozen Eclipse plugins, all inter-related and living in different subfolders. The build was converted to a multi-module manifest-first Tycho build a couple of years ago and it works quite well.

One of the plugins is rather key, and can also be built as a standalone Java app, which doesn't use an Eclipse runtime. Currently it has its own POM file (pom-standalone.xml) so that Jenkins can build the standalone app separately and the Tycho build knows nothing about it - the pom-standalone just lists the previously-built plugin jars (thanks Tycho!) and Eclipse libraries that it needs as dependencies. Couple problems with this approach though:

  • I cannot easily use IntelliJ to work on the standalone project with Maven dependency management, because it doesn't recognize the custom pom-standalone.xml filename as a POM.

    • The many jars that this project relies on are checked in to the project for the sake of Tycho and the Eclipse Manifest file, but they're also managed by Maven for the standalone build. So any dependencies have to be added to the pom-standalone.xml file AND entered into the OSGi manifest AND checked in to the source control for Eclipse purposes.

It seems like a straightforward workaround would be to tell Tycho/modules to use something other than pom.xml for the submodule's POM, or perhaps all the multimodule POM files, since Eclipse doesn't use those anyway - then the pom-standalone.xml can be converted to pom.xml and then IntelliJ will be fine with it.

I know you can specify the -f attribute to Maven builds, but will that really apply to all submodules? Can you specify the POM filename for just ONE submodule?

Are there alternative solutions? Eclipse/Tycho/p2 builds seem somewhat of a headache requiring manual library management and checking in libraries to source control, but maybe there have been changes I'm not aware of in the Eclipse build world the last few years.

Found a Similar Question that didn't help much.

Rebuke answered 28/10, 2015 at 16:25 Comment(0)
G
13

You can include projects in an aggregator POM by specifying the full name to the POM file with custom name. Example:

<modules>
    <module>org.example.bundle1</module>
    <module>org.example.bundle2</module>
    <module>org.example.keybundle/pom-tycho.xml</module>
</modules>

This both works in a pure Maven and Maven/Tycho build.

Glabrous answered 3/11, 2015 at 8:42 Comment(2)
Thank you! I could not find that information anywhere. Now if only I knew how to avoid checking in all those jars for the eclipse build.Rebuke
@Rebuke - If your jars are mvn install to the local maven repository, or mvn deploy to the remote maven repository, then your pom can just list them as dependencies and maven will retrieve them for the build. Tell Eclipse to do a maven update to pick up any changes in the pom.Mella
M
2

To extend @oberlies answer a little bit:

SCENARIO: top aggregation POM comes in multiple flavors, so any style can be built from the top.

<!-- in file pom.xml -->
<modules>
  <module>org.example.bundle1</module>
  <module>org.example.bundle2</module>
  <module>org.example.keybundle</module>
</modules>

All submodules will be built using their standard pom.xml

and

<!-- in file pom-tycho.xml -->
<modules>
  <module>org.example.bundle1/pom.xml</module>
  <module>org.example.bundle2/pom.xml</module>
  <module>org.example.keybundle/pom-tycho.xml</module>
</modules>

Submodules will be built using the specifically named POM file.

and, likewise:

<!-- in file pom-special.xml -->
<modules>
  <module>org.example.bundle1/pom.xml</module>
  <module>org.example.bundle2/pom-special.xml</module>
  <module>org.example.keybundle/pom-tycho.xml</module>
</modules>

Submodules that have custom POM files use them, and others state they still want the normal POM file, all independent of the name of the top aggregation POM file.

Because mvn -f pom-tycho.xml assumes that file name in all submodules. So if you do want pom.xml in any submodule when the top file isn't named pom.xml you need to fully specify for each submodule.

Mella answered 21/12, 2016 at 22:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.