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   *
13   * @since 0.3
14   */
15  public final class EnforcerValidator implements MavenValidator {
16  
17      /**
18       * Default constructor.
19       */
20      public EnforcerValidator() {
21          // nothing to initialize
22      }
23  
24      @Override
25      public void validate(final MavenEnvironment env)
26          throws ValidationException {
27          if (!env.exclude("enforcer", "")) {
28              final Properties props = new Properties();
29              final Properties rules = new Properties();
30              props.put("rules", rules);
31              final Properties maven = new Properties();
32              rules.put("requireMavenVersion", maven);
33              maven.put("version", "3.0");
34              final Properties java = new Properties();
35              rules.put("requireJavaVersion", java);
36              java.put("version", "1.7");
37              env.executor().execute(
38                  "org.apache.maven.plugins:maven-enforcer-plugin:3.1.0",
39                  "enforce",
40                  props
41              );
42          }
43      }
44  }