4

My project has a parent pom and several submodule poms. I've put a plugin in the parent that is responsible for building our installer distributables (using install4j). It doesn't make sense to have this plugin run on the submodules, so I've put false in the plugin's config, as seen below. The problem is, when I run mvn clean install install4j:compile <other variables here>, it cleans, compiles, and runs the install4j plugin on the parent, but then it tries to run it on the child modules and crashes.

Here's the plugin config

<plugin>
    <groupId>com.google.code.maven-install4j</groupId>
    <artifactId>maven-install4j-plugin</artifactId>
    <version>0.1.1</version>
    <inherited>false</inherited>
    <configuration>
        <executable>${devenv.install4jc}</executable>
        <configFile>${basedir}/newinstaller/ehd-demo.install4j</configFile>
        <releaseId>${project.version}</releaseId>
        <attach>false</attach>
        <skipOnMissingExecutable>true</skipOnMissingExecutable>
    </configuration>
</plugin>

Am I misunderstanding the purpose of inherited=false? What is the correct way to get this to work?

I'm using Maven 2.2.0.

Lii
  • 11,553
  • 8
  • 64
  • 88
UrLicht
  • 939
  • 1
  • 14
  • 25

2 Answers2

2

I've found this can work a couple of ways. The way I'm doing it now...

  1. Took out <inherited>false</inherited>
  2. First run mvn clean install
  3. Then run mvn install4j:compile -N (for non-recursive)

The plugin could also use the @aggregator annotation to achieve the same effect.

Lii
  • 11,553
  • 8
  • 64
  • 88
UrLicht
  • 939
  • 1
  • 14
  • 25
  • 1
    The inherited tag in the plugin is only useful to prevent poms that use this one as a parent from using the plugin. Your real problem (which as I understand it is also mine) is that your pom is also an aggregator (with submodules) and you want to keep the module from being run on the submodules. Running with -N will do that for the specific install4j plugin, but it won't solve it in normal cases where you just want to run mvn package for all plugins (since no plugin will be recursively called). So, I'd say that doesn't solve the general problem, but I don't have a better idea... – Miquel Apr 20 '12 at 16:35
  • 2
    Also, Dear StackOverflow. I really like the feature where I can get downvoted on my own answer to my own two year old question when no one else had any ideas how to fix the problem. – UrLicht May 08 '12 at 16:06
  • In the newer @Mojo annotations, you can trigger this behavior by adding an attribute to the annotation of aggregator = true. For plugins that are supposed to be executed only once per multi-module project, making them an aggregator is a great way to go. – Dan Smith Oct 01 '15 at 22:53
  • Thanks, -N is the only solution working for me, having also unsuccessfully tried false and the stuff – pma Jan 09 '20 at 11:30
1

You can run the plugin in the profile with activation condition, its kind of ugly though :-(

    <profile>
        <id>only-in-root</id>
        <activation>
            <file>
                <exists>this-file-exist-only-in-parent-project.xml</exists>
            </file>
        </activation>
Daniel Kec
  • 529
  • 2
  • 8