Check maven version in pom.xml

The project I'm working on is only building with maven-2.2: for earlier versions, the dependencies are not fixed correctly.

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

+4
source share
1 answer

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

<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> 
+8
source

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


All Articles