Otto Allmendinger
Otto Allmendinger

Reputation: 28288

Check maven version in pom.xml

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?

Upvotes: 4

Views: 5333

Answers (1)

eis
eis

Reputation: 53543

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>

Upvotes: 8

Related Questions