Skip to content

Commit 3f31138

Browse files
author
Anders Breid
authored
Primary version fetched from pom not application.properties
Improvements: * Now fetches version and application name from pom.xml * New default-application.properties contains properties that should not be changed after release. * build.version property in application.properties may be set but should be empty by default, will render an extra version after the primary version within ()
1 parent 4390a6a commit 3f31138

File tree

5 files changed

+45
-7
lines changed

5 files changed

+45
-7
lines changed

pom.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,22 @@
292292

293293
</dependencies>
294294
<build>
295+
<resources>
296+
<resource>
297+
<directory>src/main/resources</directory>
298+
<filtering>true</filtering>
299+
<includes>
300+
<include>**/default-application.properties</include>
301+
</includes>
302+
</resource>
303+
<resource>
304+
<directory>src/main/resources</directory>
305+
<filtering>false</filtering>
306+
<excludes>
307+
<exclude>**/default-application.properties</exclude>
308+
</excludes>
309+
</resource>
310+
</resources>
295311
<plugins>
296312
<plugin>
297313
<groupId>org.springframework.boot</groupId>

src/main/java/com/ericsson/ei/controller/model/ParseInstanceInfoEI.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,35 @@
2424
import com.ericsson.ei.subscriptionhandler.SubscriptionHandler;
2525
import com.ericsson.ei.waitlist.WaitListStorageHandler;
2626
import lombok.Getter;
27+
2728
import org.springframework.beans.factory.annotation.Autowired;
2829
import org.springframework.beans.factory.annotation.Value;
2930
import org.springframework.stereotype.Component;
3031

32+
import java.io.FileNotFoundException;
33+
import java.io.FileReader;
34+
import java.io.IOException;
3135
import java.util.List;
36+
import java.util.Properties;
37+
38+
import javax.annotation.PostConstruct;
3239

3340
/**
3441
* Parsing all classes which contains value annotation in eiffel-intelligence plugin.
3542
* Needed for generate Json file with information about backend instance.
3643
*/
3744
@Component
3845
public class ParseInstanceInfoEI {
39-
4046
@Getter
41-
@Value("${spring.application.name}")
42-
private String applicationName;
47+
@Value("${build.version:#{null}}")
48+
private String applicationPropertiesVersion;
4349

4450
@Getter
45-
@Value("${build.version}")
4651
private String version;
4752

53+
@Getter
54+
private String applicationName;
55+
4856
@Getter
4957
@Value("${rules.path}")
5058
private String rulesPath;
@@ -97,7 +105,12 @@ public class ParseInstanceInfoEI {
97105
@Autowired
98106
private ERQueryService erUrl;
99107

100-
public ParseInstanceInfoEI(){
108+
@PostConstruct
109+
public void init() throws IOException {
110+
Properties properties = new Properties();
111+
properties.load(ParseInstanceInfoEI.class.getResourceAsStream("/default-application.properties"));
112+
version = properties.getProperty("version");
113+
applicationName = properties.getProperty("artifactId");
101114
}
102115

103116
@Component

src/main/resources/application.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
spring.application.name=eiffel-intelligence
22
#${project.artifactId}
33

4-
build.version=@project.version@
4+
# An extra optional version tag, version will be added after github release version
5+
# Example if build.version=1.2.3-internal becomes Version 0.0.18 (1.2.3-internal)
6+
build.version=
57

68
# port where Eiffel Intelligence will run
79
server.port: 8090
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
artifactId=@project.artifactId@
2+
version=@project.version@

src/test/java/com/ericsson/ei/rules/test/TestRulesRestAPI.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,13 @@ public void testAggregationRestApi() throws Exception {
142142
}
143143
}
144144

145+
/**
146+
* TestRulePageEnabled should always be false when pushed to Github.
147+
*
148+
* @throws Exception
149+
*/
145150
@Test
146-
public void testGetTestRulePageEnabledAPI_setPropertyDefult() throws Exception {
151+
public void testGetTestRulePageEnabledAPI_ensurePropertyFalse() throws Exception {
147152
String responseBody = new JSONObject().put("status", false).toString();
148153
mockMvc.perform(MockMvcRequestBuilders.get("/rules/rule-check/testRulePageEnabled")
149154
.accept(MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk())

0 commit comments

Comments
 (0)