View Javadoc
1   /*
2    * SPDX-FileCopyrightText: Copyright (c) 2011-2026 Yegor Bugayenko
3    * SPDX-License-Identifier: MIT
4    */
5   package com.qulice.maven;
6   
7   import com.qulice.spi.ValidationException;
8   import java.util.Properties;
9   
10  /**
11   * Validate with maven-enforcer-plugin.
12   * @since 0.3
13   */
14  public final class EnforcerValidator implements MavenValidator {
15  
16      /**
17       * Default constructor.
18       */
19      public EnforcerValidator() {
20          // nothing to initialize
21      }
22  
23      @Override
24      public void validate(final MavenEnvironment env)
25          throws ValidationException {
26          if (!env.exclude("enforcer", "")) {
27              final Properties props = new Properties();
28              final Properties rules = new Properties();
29              props.put("rules", rules);
30              final Properties maven = new Properties();
31              rules.put("requireMavenVersion", maven);
32              maven.put("version", "3.0");
33              final Properties java = new Properties();
34              rules.put("requireJavaVersion", java);
35              java.put("version", "1.7");
36              env.executor().execute(
37                  "org.apache.maven.plugins:maven-enforcer-plugin:3.1.0",
38                  "enforce",
39                  props
40              );
41          }
42      }
43  }