0

I have a parent pom file which declares some modules, like

<modules>
    <module>execution</module>
    <module>model</module>
</modules>

The thing is there is a bash script bootstrap.sh on the same level as the parent pom.xml which I want to execute before the builiding of the modules listed above is started.

Is it possible to do so with maven? Or there is another way to have the bootstrap.sh executed before the compilation of the modules begins.

Some Name
  • 8,555
  • 5
  • 27
  • 77

1 Answers1

1

When building multi module projects, aggregator will be built first, and modules will be built in an order based on the dependencies between them.

You can add the following plugin to your aggregator(it's the parent pom you mentioned in the question) pom.xml to solve your problem. I choose initialize for this to be executed, but You could have choose install also. Check out lifecycle. Imported thing here this code will be executed when a maven command that is later in the lifecycle is issued. (Ex: If You choose install as the phase, and execute mvn package this wont be executed.)

<build>
  <plugins>
    <plugin>
      <artifactId>exec-maven-plugin</artifactId>
      <groupId>org.codehaus.mojo</groupId>
      <version>1.6.0</version>
      <executions>
        <execution>
          <id>Run Script</id>
          <phase>initialize</phase>
          <goals>
            <goal>exec</goal>
          </goals>
          <configuration>
            <executable>bootstrap.sh</executable>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>
miskender
  • 7,460
  • 1
  • 19
  • 23