Commit d0eba7a0 by Tuomas Riihimäki

Fix parsing of git version from package generation

There was already a somewhat broken version of maven
plugin which saves the current git versions from build
time. Fixed it.. :)
1 parent ac295b49
......@@ -23,7 +23,6 @@
<!-- The path for the to be generated properties file, it's relative
to ${project.basedir} -->
<generateGitPropertiesFilename>src/main/java/moya-git.properties</generateGitPropertiesFilename>
<dotGitDirectory>${project.basedir}/../../.git</dotGitDirectory>
</configuration>
</plugin>
......
......@@ -18,6 +18,9 @@
*/
package fi.codecrew.moya.utilities;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
......@@ -25,100 +28,43 @@ import java.util.Properties;
public class GitRepositoryState {
private static GitRepositoryState gitRepositoryState;
private static final Logger logger = LoggerFactory.getLogger(GitRepositoryState.class);
private final Properties properties;
public static GitRepositoryState getGitRepositoryState() throws IOException
{
public static GitRepositoryState getGitRepositoryState() {
if (gitRepositoryState == null) {
gitRepositoryState = new GitRepositoryState();
}
return gitRepositoryState;
}
private final String branch;
private final String describe;
private final String describeShort;
private final String commitId;
private final String buildUserName;
private final String buildUserEmail;
private final String buildTime;
private final String commitUserName;
private final String commitUserEmail;
private final String commitMessageShort;
private final String commitMessageFull;
private final String commitTime;
private GitRepositoryState() throws IOException
{
InputStream resource = getClass().getClassLoader().getResourceAsStream("moya-git.properties");
if (resource == null)
{
throw new IOException("ResourceFile not found");
}
Properties properties = new Properties();
properties.load(resource);
this.branch = properties.get("git.branch").toString();
this.describe = properties.get("git.commit.id.describe").toString();
this.describeShort = properties.get("git.commit.id.describe-short").toString();
this.commitId = properties.get("git.commit.id").toString();
this.buildUserName = properties.get("git.build.user.name").toString();
this.buildUserEmail = properties.get("git.build.user.email").toString();
this.buildTime = properties.get("git.build.time").toString();
this.commitUserName = properties.get("git.commit.user.name").toString();
this.commitUserEmail = properties.get("git.commit.user.email").toString();
this.commitMessageShort = properties.get("git.commit.message.short").toString();
this.commitMessageFull = properties.get("git.commit.message.full").toString();
this.commitTime = properties.get("git.commit.time").toString();
}
public String getBranch() {
return branch;
}
public String getDescribe() {
return describe;
}
public String getDescribeShort() {
return describeShort;
}
public String getCommitId() {
return commitId;
}
private GitRepositoryState() {
logger.info("Initializing git status");
this.properties = new Properties();
try {
InputStream resource = getClass().getResourceAsStream("/git.properties");
public String getBuildUserName() {
return buildUserName;
if (resource == null) {
logger.warn("Resource not found!");
return;
}
public String getBuildUserEmail() {
return buildUserEmail;
this.properties.load(resource);
logger.info("Git keys:", this.properties.keys());
} catch (IOException e) {
logger.warn("Error initializing git proerties", e);
}
public String getBuildTime() {
return buildTime;
}
public String getCommitUserName() {
return commitUserName;
public String getProperty(String key) {
String retStr = null;
if (properties != null || key != null) {
Object ret = properties.get(key);
if (ret != null) {
retStr = ret.toString();
}
public String getCommitUserEmail() {
return commitUserEmail;
}
public String getCommitMessageShort() {
return commitMessageShort;
}
public String getCommitMessageFull() {
return commitMessageFull;
}
public String getCommitTime() {
return commitTime;
return retStr;
}
}
......@@ -14,6 +14,15 @@
<h:commandButton action="#{testView.resetMenu()}" value="Reset to newui menu" onclick="return confirm('THIS WILL RESET ALL MODIFICATIONS TO DEFAULT MENU!!\n Are you really sure?!');" />
<h:commandButton action="#{testView.resetOldMenu()}" value="Reset to old menu" onclick="return confirm('THIS WILL RESET ALL MODIFICATIONS TO DEFAULT MENU!!\n Are you really sure?!');" />
</h:form>
<ul>
<li>Build time #{testView.gitProps.getProperty('git.build.time')}</li>
<li>Build user: #{testView.gitProps.getProperty('git.build.user.name')}</li>
<li>Commit time #{testView.gitProps.getProperty('git.commit.time')}</li>
<li>Git id #{testView.gitProps.getProperty('git.commit.id.abbrev')}</li>
</ul>
</ui:define>
</ui:composition>
</h:body>
......
......@@ -30,6 +30,7 @@ import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import fi.codecrew.moya.utilities.GitRepositoryState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -105,6 +106,10 @@ public class TestDataView extends GenericCDIView {
return null;
}
public GitRepositoryState getGitProps() {
return GitRepositoryState.getGitRepositoryState();
}
public void sendMultibuggageSpam() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!