1 /*
2 * Copyright 2011-2025 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 org.apache.maven.plugin.MojoFailureException;
25 import org.apache.maven.plugin.logging.Log;
26
27 /**
28 * The Class PortableGit.
29 */
30 public class PortableGit {
31
32 /** The group id. */
33 private String groupId;
34
35 /** The artifact id. */
36 private String artifactId;
37
38 /** The version. */
39 private String version;
40
41 /** The extension. */
42 private String extension;
43
44 /** The classifier. */
45 private String classifier;
46
47 /** The name. */
48 private String name;
49
50 /**
51 * Gets the group id.
52 *
53 * @return the group id
54 */
55 public String getGroupId() {
56 return groupId;
57 }
58
59 /**
60 * Gets the artifact id.
61 *
62 * @return the artifact id
63 */
64 public String getArtifactId() {
65 return artifactId;
66 }
67
68 /**
69 * Gets the version.
70 *
71 * @return the version
72 */
73 public String getVersion() {
74 return version;
75 }
76
77 /**
78 * Gets the extension.
79 *
80 * @return the extension
81 */
82 public String getExtension() {
83 return extension;
84 }
85
86 /**
87 * Gets the classifier.
88 *
89 * @return the classifier
90 */
91 public String getClassifier() {
92 return classifier;
93 }
94
95 /**
96 * Gets the name.
97 *
98 * @return the name
99 */
100 public String getName() {
101 return name;
102 }
103
104 /**
105 * Load portable git artifact from makeself.properties file.
106 *
107 * @param log
108 * the log
109 *
110 * @throws MojoFailureException
111 * the mojo failure exception
112 */
113 public PortableGit(final Log log) throws MojoFailureException {
114 try (InputStream input = this.getClass().getClassLoader().getResourceAsStream("META-INF/makeself.properties")) {
115 final Properties properties = new Properties();
116 properties.load(input);
117
118 this.groupId = properties.getProperty("portable.git.groupId");
119 this.artifactId = properties.getProperty("portable.git.artifactId");
120 this.version = properties.getProperty("portable.git.version");
121 this.extension = properties.getProperty("portable.git.extension");
122 this.classifier = properties.getProperty("portable.git.classifier");
123 this.name = properties.getProperty("portable.git.name");
124 } catch (final IOException e) {
125 log.error("Unable to read makeself.properties");
126 throw new MojoFailureException(e);
127 }
128 }
129
130 }