Skip to content

Commit

Permalink
added Version class for keeping the exact release version of Scoold
Browse files Browse the repository at this point in the history
  • Loading branch information
albogdano committed Mar 31, 2022
1 parent fd2312b commit 76aefd3
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 3 deletions.
39 changes: 39 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,23 @@
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<id>generate-verion-class</id>
<goals>
<goal>filter-sources</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<resources>
<resource>
<directory>src/main/resources</directory>
Expand All @@ -174,6 +191,28 @@
</resources>

<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<revisionOnScmFailure>UNKNOWN</revisionOnScmFailure>
<getRevisionOnlyOnce>true</getRevisionOnlyOnce>
</configuration>
<executions>
<execution>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
Expand Down
56 changes: 56 additions & 0 deletions src/main/java-templates/com/erudika/scoold/utils/Version.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2013-2022 Erudika. https://erudika.com
*
* 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.
*
* For issues and patches go to: https://github.com/erudika
*/
package com.erudika.scoold.utils;

/**
* GENERATED CLASS. DO NOT MODIFY!
* @author Alex Bogdanovski [[email protected]]
*/
public final class Version {

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 GIT = "${project.scm.developerConnection}";
private static final String GIT_BRANCH = "${scmBranch}";
private static final String REVISION = "${buildNumber}";

public static String getVersion() {
return VERSION;
}

public static String getArtifactId() {
return ARTIFACTID;
}

public static String getGroupId() {
return GROUPID;
}

public static String getGIT() {
return GIT;
}

public static String getRevision() {
return REVISION;
}

public static String getGITBranch() {
return GIT_BRANCH;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.erudika.scoold.core.Question;
import com.erudika.scoold.core.Reply;
import com.erudika.scoold.utils.ScooldUtils;
import com.erudika.scoold.utils.Version;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.MapperFeature;
Expand Down Expand Up @@ -100,7 +101,6 @@ public class AdminController {

private static final Logger logger = LoggerFactory.getLogger(AdminController.class);
private static final ScooldConfig CONF = ScooldUtils.getConfig();
private final String scooldVersion = getClass().getPackage().getImplementationVersion();
private static final int MAX_SPACES = 10; // Hey! It's cool to edit this, but please consider buying Scoold Pro! :)
private final String soDateFormat1 = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
private final String soDateFormat2 = "yyyy-MM-dd'T'HH:mm:ss'Z'";
Expand Down Expand Up @@ -145,7 +145,8 @@ public String get(HttpServletRequest req, Model model) {
model.addAttribute("itemcount", itemcount);
model.addAttribute("itemcount1", itemcount1);
model.addAttribute("isDefaultSpacePublic", utils.isDefaultSpacePublic());
model.addAttribute("scooldVersion", Optional.ofNullable(scooldVersion).orElse("unknown"));
model.addAttribute("scooldVersion", Version.getVersion());
model.addAttribute("scooldRevision", Version.getRevision());
String importedCount = req.getParameter("imported");
if (importedCount != null) {
if (req.getParameter("success") != null) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/templates/admin.vm
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@
<div class="collapsible-header"><i class="fa fa-info-circle grey-text"></i>$!lang.get('admin.environment')</div>
<div class="collapsible-body">
<table class="highlight">
<tr><td><h4>Scoold</h4></td> <td><code>version $!scooldVersion</code></td></tr>
<tr><td><h4>Scoold</h4></td>
<td>version <code>$!scooldVersion</code> <small>(rev. <code>$!scooldRevision</code>)</small></td></tr>
<tr><td><h4>Production mode</h4></td> <td><code>$!IN_PRODUCTION</code></td></tr>
<tr><td><h4>Para app</h4></td> <td><code>$!paraapp</code></td></tr>
<tr><td><h4>Para version</h4></td> <td><code>$!version</code></td></tr>
Expand Down

0 comments on commit 76aefd3

Please sign in to comment.