View Javadoc
1   /*
2    *    Copyright 2011-2024 the original author or authors.
3    *
4    *    This program is free software; you can redistribute it and/or
5    *    modify it under the terms of the GNU General Public License
6    *    as published by the Free Software Foundation; either version 2
7    *    of the License, or (at your option) any later version.
8    *
9    *    You may obtain a copy of the License at
10   *
11   *       https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
12   *
13   *    This program is distributed in the hope that it will be useful,
14   *    but WITHOUT ANY WARRANTY; without even the implied warranty of
15   *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   *    GNU General Public License for more details.
17   */
18  package com.hazendaz.maven.makeself;
19  
20  import java.io.IOException;
21  import java.io.InputStream;
22  import java.util.Properties;
23  
24  import lombok.Getter;
25  
26  import org.apache.maven.plugin.MojoFailureException;
27  import org.apache.maven.plugin.logging.Log;
28  
29  /**
30   * The Class PortableGit.
31   */
32  public class PortableGit {
33  
34      /** The group id. */
35      @Getter
36      private String groupId;
37  
38      /** The artifact id. */
39      @Getter
40      private String artifactId;
41  
42      /** The version. */
43      @Getter
44      private String version;
45  
46      /** The extension. */
47      @Getter
48      private String extension;
49  
50      /** The classifier. */
51      @Getter
52      private String classifier;
53  
54      /** The name. */
55      @Getter
56      private String name;
57  
58      /**
59       * Load portable git artifact from makeself.properties file.
60       *
61       * @param log
62       *            the log
63       *
64       * @throws MojoFailureException
65       *             the mojo failure exception
66       */
67      public PortableGit(final Log log) throws MojoFailureException {
68          try (InputStream input = this.getClass().getClassLoader().getResourceAsStream("META-INF/makeself.properties")) {
69              final Properties properties = new Properties();
70              properties.load(input);
71  
72              this.groupId = properties.getProperty("portable.git.groupId");
73              this.artifactId = properties.getProperty("portable.git.artifactId");
74              this.version = properties.getProperty("portable.git.version");
75              this.extension = properties.getProperty("portable.git.extension");
76              this.classifier = properties.getProperty("portable.git.classifier");
77              this.name = properties.getProperty("portable.git.name");
78          } catch (final IOException e) {
79              log.error("Unable to read makeself.properties");
80              throw new MojoFailureException(e);
81          }
82      }
83  
84  }