View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.lifecycle.providers;
20  
21  import java.io.IOException;
22  import java.io.InputStream;
23  import java.io.UncheckedIOException;
24  import java.util.Properties;
25  
26  import static java.util.Objects.requireNonNull;
27  
28  /**
29   * Provider of plugin versions.
30   *
31   * @since 3.10.0
32   */
33  public final class PluginVersions {
34      private PluginVersions() {}
35  
36      // basic
37      public static final String RESOURCES_PLUGIN_VERSION;
38      public static final String COMPILER_PLUGIN_VERSION;
39      public static final String SUREFIRE_PLUGIN_VERSION;
40      public static final String INSTALL_PLUGIN_VERSION;
41      public static final String DEPLOY_PLUGIN_VERSION;
42      // packaging
43      public static final String JAR_PLUGIN_VERSION;
44      public static final String EAR_PLUGIN_VERSION;
45      public static final String EJB_PLUGIN_VERSION;
46      public static final String PLUGIN_PLUGIN_VERSION;
47      public static final String RAR_PLUGIN_VERSION;
48      public static final String WAR_PLUGIN_VERSION;
49      // lifecycles
50      public static final String CLEAN_PLUGIN_VERSION;
51      public static final String SITE_PLUGIN_VERSION;
52  
53      static {
54          Properties properties = new Properties();
55          try {
56              try (InputStream inputStream = PluginVersions.class
57                      .getClassLoader()
58                      .getResourceAsStream("org/apache/maven/lifecycle/providers/plugin-versions.properties")) {
59                  if (inputStream != null) {
60                      properties.load(inputStream);
61                  }
62              }
63              RESOURCES_PLUGIN_VERSION = requireNonNull(properties.getProperty("maven-resources-plugin"));
64              COMPILER_PLUGIN_VERSION = requireNonNull(properties.getProperty("maven-compiler-plugin"));
65              SUREFIRE_PLUGIN_VERSION = requireNonNull(properties.getProperty("maven-surefire-plugin"));
66              INSTALL_PLUGIN_VERSION = requireNonNull(properties.getProperty("maven-install-plugin"));
67              DEPLOY_PLUGIN_VERSION = requireNonNull(properties.getProperty("maven-deploy-plugin"));
68              JAR_PLUGIN_VERSION = requireNonNull(properties.getProperty("maven-jar-plugin"));
69              EAR_PLUGIN_VERSION = requireNonNull(properties.getProperty("maven-ear-plugin"));
70              EJB_PLUGIN_VERSION = requireNonNull(properties.getProperty("maven-ejb-plugin"));
71              PLUGIN_PLUGIN_VERSION = requireNonNull(properties.getProperty("maven-plugin-plugin"));
72              RAR_PLUGIN_VERSION = requireNonNull(properties.getProperty("maven-rar-plugin"));
73              WAR_PLUGIN_VERSION = requireNonNull(properties.getProperty("maven-war-plugin"));
74              CLEAN_PLUGIN_VERSION = requireNonNull(properties.getProperty("maven-clean-plugin"));
75              SITE_PLUGIN_VERSION = requireNonNull(properties.getProperty("maven-site-plugin"));
76          } catch (IOException e) {
77              throw new UncheckedIOException("Failed to load plugin versions", e);
78          }
79      }
80  }