Marcello90
Marcello90

Reputation: 1343

Testing for installed Apache Maven

i found this question (Correct way to check Java version from BASH script). I am unsure how to do the same for Apache maven. I have to make sure for an installation script that at least version 3.1.1 of Maven is installed.

Upvotes: 0

Views: 72

Answers (2)

khmarbaise
khmarbaise

Reputation: 97517

You need to do it that way, cause prerequisites is deprecated with Maven 3.

  <!-- The following is marked as deprecated with Maven 3. so using maven-enforcer-plugin instead. -->
  <!--  http://jira.codehaus.org/browse/MNG-4840 -->
  <!--  http://jira.codehaus.org/browse/MNG-5297 -->
  <prerequisites>
    <maven>${mavenVersion}</maven>
  </prerequisites>
  (...)
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-enforcer-plugin</artifactId>
    <version>1.3.1</version>
    <executions>
      <execution>
        <id>enforce-maven</id>
        <goals>
          <goal>enforce</goal>
        </goals>
        <configuration>
          <rules>
            <requireMavenVersion>
              <version>${mavenVersion}</version>
            </requireMavenVersion>
          </rules>
        </configuration>
      </execution>
    </executions>
  </plugin>

Upvotes: 1

RaviH
RaviH

Reputation: 3584

Maven has a feature to declare minimum maven version in the POM itself. You don't need to add any other check after you add this to your POM:

<prerequisites>
    <maven>3.1.1</maven>
</prerequisites>

See Prerequisites in maven documentation.

Upvotes: 0

Related Questions