Skip to content

Commit

Permalink
Added versioning to application
Browse files Browse the repository at this point in the history
  • Loading branch information
DJ Spiess committed Sep 5, 2016
1 parent 2f3961a commit 0b41504
Show file tree
Hide file tree
Showing 5 changed files with 202 additions and 73 deletions.
5 changes: 0 additions & 5 deletions .gitignore
@@ -1,13 +1,8 @@
*.class
/target/

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
237 changes: 178 additions & 59 deletions pom.xml
@@ -1,66 +1,185 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.deegeu</groupId>
<artifactId>deegeu-quizzer</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>deegeu-quizzer</name>
<url>http://www.deegeu.com</url>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.deegeu</groupId>
<artifactId>deegeu-quizzer</artifactId>
<packaging>war</packaging>
<version>${project.version}.${build.number}</version>
<name>deegeu-quizzer</name>
<url>http://www.deegeu.com</url>

<properties>
<version.wildfly.swarm>1.0.0.Final</version.wildfly.swarm>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<developers>
<developer>
<id>djspiess</id>
<organization>DJ Spiess</organization>
<organizationUrl>http://www.deegeu.com</organizationUrl>
<roles>
<role>developer</role>
</roles>
</developer>
</developers>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>bom</artifactId>
<version>${version.wildfly.swarm}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<project.version>SNAPSHOT</project.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.wildfly.swarm>1.0.0.Final</version.wildfly.swarm>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>4.12</junit.version>

<jar.finalName>${project.name}.${project.version}</jar.finalName>
<build.manifest.section>Build Details</build.manifest.section>
<build.unknown>UNKNOWN</build.unknown>
<build.number>${build.unknown}</build.number>
<build.revision>${git.commit.id.describe-short}</build.revision>
<repository.utilities.version>[1.0,)</repository.utilities.version>
</properties>

<build>
<finalName>deegeu-quizzer</finalName>
<plugins>
<plugin>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-plugin</artifactId>
<version>${version.wildfly.swarm}</version>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>releases</id>
<url>http://nexus-deege.rhcloud.com/nexus/content/repositories/releases</url>
</repository>
</repositories>


<distributionManagement>
<repository>
<id>releases</id>
<url>http://nexus-deege.rhcloud.com/nexus/content/repositories/releases</url>
</repository>
</distributionManagement>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>bom</artifactId>
<version>${version.wildfly.swarm}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<finalName>${jar.finalName}</finalName>
<plugins>
<plugin>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-plugin</artifactId>
<version>${version.wildfly.swarm}</version>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Build-Time>${maven.build.timestamp}</Build-Time>
</manifestEntries>
<manifestSections>
<manifestSection>
<name>${build.manifest.section}</name>
<manifestEntries>
<Implementation-Title>${project.name}</Implementation-Title>
<Implementation-Version>${project.version}</Implementation-Version>
<Implementation-Build-Number>${build.number}</Implementation-Build-Number>
<Implementation-SCM-Revision>${build.revision}</Implementation-SCM-Revision>
</manifestEntries>
</manifestSection>
</manifestSections>
</archive>
<finalName>${jar.finalName}</finalName>
</configuration>
</plugin>

<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>

<configuration>
<!-- <dotGitDirectory>${project.basedir}/.git</dotGitDirectory> -->
<prefix>git</prefix>
<dateFormat>dd.MM.yyyy '@' HH:mm:ss z</dateFormat>
<dateFormatTimeZone>${user.timezone}</dateFormatTimeZone>
<verbose>true</verbose>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
<format>properties</format>
<skipPoms>true</skipPoms>
<injectAllReactorProjects>true</injectAllReactorProjects>
<failOnNoGitDirectory>true</failOnNoGitDirectory>
<failOnUnableToExtractRepoInfo>true</failOnUnableToExtractRepoInfo>
<skip>false</skip>
<runOnlyOnce>false</runOnlyOnce>
<useNativeGit>false</useNativeGit>
<abbrevLength>7</abbrevLength>
<commitIdGenerationMode>flat</commitIdGenerationMode>
<gitDescribe>
<skip>false</skip>
<always>false</always>
<abbrev>7</abbrev>
<dirty>-dirty</dirty>
<match>*</match>
<forceLongFormat>false</forceLongFormat>
</gitDescribe>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.deegeu.utilities</groupId>
<artifactId>repository-utils</artifactId>
<version>${repository.utilities.version}</version>
</dependency>

<!-- Java EE 7 dependency -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<!-- Wildfly Swarm Fractions -->
</dependencies>
<!-- Java EE 7 dependency -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<!-- Wildfly Swarm Fractions -->
</dependencies>
</project>
27 changes: 22 additions & 5 deletions src/main/java/com/deegeu/trivia/TriviaApp.java
Expand Up @@ -23,7 +23,6 @@
*/
package com.deegeu.trivia;


import java.util.Date;
import javax.ws.rs.core.Application;
import javax.ws.rs.ApplicationPath;
Expand All @@ -35,6 +34,9 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import com.deegeu.utilities.git.GitRepositoryState;
import java.io.IOException;
import java.util.Properties;

/**
* JAX-RS application. Root path is /trivia
Expand All @@ -43,22 +45,37 @@
@ApplicationPath("/trivia")
@Path("")
public class TriviaApp extends Application {

private GitRepositoryState gitRepositoryState;

public TriviaApp() {
try {
if (gitRepositoryState == null) {
Properties properties = new Properties();
properties.load(getClass().getClassLoader().getResourceAsStream("git.properties"));
gitRepositoryState = new GitRepositoryState(properties);
}
} catch (IOException ioe) {
System.err.println("ERROR: Can't read git.properties: " + ioe.getMessage());
}
}

@GET
@Produces(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response getDirectory(@Context UriInfo uri) {
Link selfLink = Link.fromUri(uri.getBaseUri())
.rel("self").type(MediaType.APPLICATION_JSON)
.build();
Link questionsLink = Link.fromUri(uri.getBaseUri() + "questions")
.rel("questions").type(MediaType.APPLICATION_JSON)
.build();

return Response.ok()
.lastModified(new Date())
.header("trivia-version", "1.0")
.header("trivia-version", gitRepositoryState.getBuildVersion())
.location(uri.getRequestUri())
.links(selfLink, questionsLink)
.build();
}

}
Expand Up @@ -4,9 +4,9 @@
import static org.junit.Assert.*;

/**
* Unit test for simple App.
* Unit test for simple TriviaApp.
*/
public class AppTest {
public class TriviaAppTest {

/**
* Rigorous Test :-)
Expand Down
Expand Up @@ -5,8 +5,6 @@
*/
package com.deegeu.trivia.model;

import com.deegeu.trivia.model.TriviaQuestion;
import com.deegeu.trivia.model.TriviaQuestionBuilder;
import java.util.Date;
import org.junit.*;
import static org.junit.Assert.*;
Expand Down

0 comments on commit 0b41504

Please sign in to comment.