views:

119

answers:

1

Hi everyone.

I have this multi-module project.

In the beginning of each build I would like to run some bat file.

So i did the following:

<profile>
            <id>deploy-db</id>
            <build>
                <plugins>
 <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.1.1</version>
        </plugin>
                </plugins>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.codehaus.mojo</groupId>
                            <artifactId>exec-maven-plugin</artifactId>
                            <version>1.1.1</version>
                            <executions>
                                <execution>
                                    <phase>validate</phase>
                                    <goals>
                                        <goal>exec</goal>
                                    </goals>
                                    <inherited>false</inherited>
                                </execution>
                            </executions>
                            <configuration>
                                <executable>../database/schemas/import_databases.bat</executable>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>

when i run the mvn verify -Pdeploy-db from the root I get this script executed over and over again in each of my modules.

I want it to be executed only once, in the root module.

What is there that I am missing ?

Thanks

+1  A: 

I might be mistaken but when you add a plugin to the <pluginManagement> section each and every sub-module inherits it and "runs" it.

I think that you should move you exec-maven-plugin and its <execution> to the normal <plugins> section.

Yaneeve
This is not quite right. PluginManagment only configures the plugin. Not telling him anything about being applied.In short , that does not work ...
Roman
when you add the execution section - that does say something about its invocation...
Yaneeve
@Roman, run `mvn help:effective-pom` from the sub-modules to see what is inherited/what is applied and what is not
matt b
No, the problem is not the `pluginManagement` (doesn't do anything by itself).
Pascal Thivent