FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
amadeus-java/.github/VersionLibraryVerifier.java at master · jabrena/amadeus-java · GitHub
jabrena
/
amadeus-java
Public
forked from
amadeus4dev/amadeus-java
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
7
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
amadeus-java
/
.github
/
VersionLibraryVerifier.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
86 lines (75 loc) · 2.8 KB
Breadcrumbs
amadeus-java
/
.github
/
VersionLibraryVerifier.java
Copy path
File metadata and controls
86 lines (75 loc) · 2.8 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
///usr/bin/env jbang "$0" "$@" ; exit $?
import
java
.
io
.
File
;
import
java
.
io
.
FileInputStream
;
import
java
.
io
.
IOException
;
import
java
.
nio
.
file
.
Files
;
import
java
.
nio
.
file
.
Paths
;
import
java
.
util
.
Properties
;
import
java
.
util
.
List
;
import
java
.
util
.
function
.
Function
;
/**
* This Java class verify in the library that in the following files:
*
* - /gradle.properties
* - /src/main/java/com/amadeus/Amadeus.java
*
* The versions of the library continues with the same value.
*
* How to run in local:
* jbang VersionLibraryVerifier.java ./
*/
public
class
VersionLibraryVerifier
{
public
static
void
main
(
String
[]
args
) {
//Parameter
String
path
=
args
[
0
];
//Parse line to extract the version value
Function
<
String
,
String
>
extractValue
=
str
-> {
Integer
position
=
str
.
indexOf
(
"VERSION"
);
String
chuncked
=
str
.
substring
(
position
+
"VERSION"
.
length
()).
trim
();
chuncked
=
chuncked
.
replace
(
"="
,
""
).
trim
();
chuncked
=
chuncked
.
replace
(
";"
,
""
);
chuncked
=
chuncked
.
replace
(
"
\"
"
,
""
);
return
chuncked
;
};
//Get library version from Java class (Amadeus.java)
Function
<
String
,
String
>
getJavaVersion
=
param
-> {
try
{
List
<
String
>
allLines
=
Files
.
readAllLines
(
Paths
.
get
(
param
+
"/src/main/java/com/amadeus/Amadeus.java"
));
return
allLines
.
stream
()
.
filter
(
str
->
str
.
contains
(
"VERSION"
))
.
limit
(
1
)
.
map
(
extractValue
)
.
peek
(
System
.
out
::
println
)
.
findFirst
()
.
orElseThrow
(
RuntimeException
::
new
);
}
catch
(
IOException
e
) {
return
"999"
;
}
};
//Get library version from Gradle file (gradle.properties)
Function
<
String
,
String
>
getGradleVersion
=
param
-> {
try
{
Properties
properties
=
new
Properties
();
properties
.
load
(
new
FileInputStream
(
new
File
(
param
+
"gradle.properties"
)));
String
versionGradle
=
properties
.
get
(
"VERSION_NAME"
).
toString
();
System
.
out
.
println
(
versionGradle
);
return
versionGradle
;
}
catch
(
IOException
e
) {
return
"998"
;
}
};
//Process
File
userDirPath
=
new
File
(
System
.
getProperty
(
"user.dir"
));
String
directoryPath
=
userDirPath
.
getParent
() +
"/"
+
path
;
String
versionJava
=
getJavaVersion
.
apply
(
directoryPath
);
String
versionGradle
=
getGradleVersion
.
apply
(
directoryPath
);
//Assert
if
(
versionJava
.
equals
(
versionGradle
)) {
System
.
out
.
println
(
"Versions in the library are the same."
);
System
.
exit
(
0
);
}
else
{
System
.
out
.
println
(
"Versions in the library are not the same."
);
System
.
exit
(-
1
);
}
}
}
Back
|
FazBrowse Home
|
New Git URL