View Javadoc
1   /*
2    * SPDX-FileCopyrightText: Copyright (c) 2011-2025 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      @Override
18      @SuppressWarnings("PMD.AvoidDuplicateLiterals")
19      public void validate(final MavenEnvironment env)
20          throws ValidationException {
21          if (!env.exclude("enforcer", "")) {
22              final Properties props = new Properties();
23              final Properties rules = new Properties();
24              props.put("rules", rules);
25              final Properties maven = new Properties();
26              rules.put("requireMavenVersion", maven);
27              maven.put("version", "3.0");
28              final Properties java = new Properties();
29              rules.put("requireJavaVersion", java);
30              java.put("version", "1.7");
31              env.executor().execute(
32                  "org.apache.maven.plugins:maven-enforcer-plugin:3.1.0",
33                  "enforce",
34                  props
35              );
36          }
37      }
38  
39  }