Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - Fix #252 - Add "About" menu with Maven version numbers #84

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions gtfs-realtime-validator-lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,24 @@
</dependencies>

<build>
<pluginManagement>
<plugins>
<!-- Used w/ VersionUtil.java to get the Maven version number at runtime -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<id>generate-version-class</id>
<goals>
<goal>filter-sources</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -192,6 +210,34 @@
</execution>
</executions>
</plugin>

<!-- Used w/ VersionUtil.java to get the Maven version number at runtime -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
<version>1.0.0</version>
</plugin>

<!-- Used w/ VersionUtil.java to get the Git commit ID at runtime -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<revisionOnScmFailure>UNKNOWN</revisionOnScmFailure>
<getRevisionOnlyOnce>true</getRevisionOnlyOnce>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (C) 2018 University of South Florida ([email protected])
*
* Licensed under the Apache License, VersionModel 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package edu.usf.cutr.gtfsrtvalidator;

import edu.usf.cutr.gtfsrtvalidator.lib.model.VersionModel;

/**
* Class used with the templating-maven-plugin to get Maven version numbers at runtime. See https://stackoverflow.com/a/36628755/937715
*/
public class VersionUtil {

private static final String VERSION = "${project.version}";
private static final String GROUPID = "${project.groupId}";
private static final String ARTIFACTID = "${project.artifactId}";
private static final String REVISION = "${buildNumber}";

public static VersionModel getVersion() {
return new VersionModel(VERSION, GROUPID, ARTIFACTID, REVISION);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright (C) 2018 University of South Florida ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package edu.usf.cutr.gtfsrtvalidator.lib.model;

/**
* A model class to hold the information generated at build time in VersionUtil. See https://stackoverflow.com/a/36628755/937715
*/
public class VersionModel {

private String mVersion;
private String mGroupId;
private String mArtifactId;
private String mRevision;

public VersionModel() {

}

public VersionModel(String version, String groupId, String artifactId, String revision) {
mVersion = version;
mGroupId = groupId;
mArtifactId = artifactId;
mRevision = revision;
}

public String getVersion() {
return mVersion;
}

public String getGroupId() {
return mGroupId;
}

public String getArtifactId() {
return mArtifactId;
}

public String getRevision() {
return mRevision;
}

public void setVersion(String version) {
this.mVersion = version;
}

public void setGroupId(String groupId) {
this.mGroupId = mGroupId;
}

public void setArtifactId(String artifactId) {
this.mArtifactId = mArtifactId;
}

public void setRevision(String revision) {
this.mRevision = revision;
}

@Override
public String toString() {
return "VersionModel{" +
"version='" + mVersion + '\'' +
", groupId='" + mGroupId + '\'' +
", artifactId='" + mArtifactId + '\'' +
", revision='" + mRevision + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (C) 2011 Nipuna Gunathilake.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package edu.usf.cutr.gtfsrtvalidator.api.resource;

import com.fasterxml.jackson.core.JsonProcessingException;
import edu.usf.cutr.gtfsrtvalidator.VersionUtil;
import edu.usf.cutr.gtfsrtvalidator.lib.model.VersionModel;
import org.slf4j.LoggerFactory;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/version")
public class VersionApi {

private static final org.slf4j.Logger _log = LoggerFactory.getLogger(VersionApi.class);

// A call to `/api/version` returns the Maven version information for this project
@GET
@Produces(MediaType.APPLICATION_JSON)
public VersionModel getVersion() throws JsonProcessingException {
_log.info(VersionUtil.getVersion().toString());
//return mObjectMapper.writeValueAsString(VersionUtil.getVersion());
return VersionUtil.getVersion();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ var enableShapes;

var server = window.location.protocol + "//" + window.location.host;


function about() {

}

function addInput(){
if (counter == limit) {
alert("You have reached the limit of adding " + counter + " inputs");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav pull-right">
<li><a href="#">About</a></li>
<li><a href="#" role="button" onClick="about();">About</a></li>
<li><a href="#">Help</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav pull-right">
<li><a href="#">About</a></li>
<li><a href="#" role="button" onClick="about();">About</a></li>
<li><a href="#">Help</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@
<url>http://nexus.onebusaway.org/content/groups/public/</url>
</repository>
</repositories>

<scm>
<connection>scm:git:https://github.com/CUTR-at-USF/gtfs-realtime-validator.git</connection>
<url>https://github.com/CUTR-at-USF/gtfs-realtime-validator.git</url>
</scm>
</project>