Running a script from maven inside a project with multiple modules

I have this multi-module project.

At 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 mvn verify -Pdeploy-dbfrom the root, I get this script executed again and again in each of my modules.

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

What am I missing there?

thank

+3
source share
2 answers

I may be wrong, but when you add a plugin to a section <pluginManagement>, each submodule inherits it and “launches” it.

, exec-maven-plugin <execution> <plugins> .

+1

, , - POM. , maven (.. " maven" ). "leaf node" poms, , .

, script , , ( , ), . - , , .

maven. "../database/schemas/import_databases.bat". import_databases.bat , , . - "$ {basedir}/src/main/scripts/import_databases.bat"

0

Source: https://habr.com/ru/post/1738856/


All Articles