Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check maven version in pom.xml

Tags:

maven-2

maven

A project I am working on only builds with maven-2.2: for earlier versions, the dependencies aren't resolved correctly.

Is there a way abort the build with an informative error message depending on the maven version?

like image 366
Otto Allmendinger Avatar asked Feb 22 '23 20:02

Otto Allmendinger


1 Answers

Use maven-enforcer-plugin. There is an example provided, so configuration for you would be something like:

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>1.0.1</version>
        <executions>
          <execution>
            <id>enforce-versions</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireMavenVersion>
                  <version>2.2</version>
                </requireMavenVersion>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
like image 66
eis Avatar answered Mar 02 '23 23:03

eis