-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfoo.java
199 lines (182 loc) · 7.95 KB
/
foo.java
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
import java.io.File;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Map;
import java.util.TreeMap;
public class foo {
static String[] extensions = new String[] {
// "agroal",
// "artemis-jms",
// "config-yaml",
// "core",
"elytron-security",
// "gizmo",
"hibernate-orm",
"hibernate-orm-panache",
"hibernate-validator",
"jackson",
"jaxb",
"jdbc-mariadb",
"jdbc-mssql",
"jdbc-mysql",
"jdbc-postgresql",
"jsonb",
"jsonp",
"kafka-client",
// "keycloak-authorization", //https://github.com/quarkusio/quarkus/issues/7561
"quarkus-kubernetes",
"narayana-jta",
// "oidc", //https://github.com/quarkusio/quarkus/issues/7561
"quartz",
// "reactive-pg-client",
"rest-client",
"resteasy",
"resteasy-jackson",
"resteasy-jsonb",
"resteasy-jaxb",
"scheduler",
"smallrye-context-propagation",
"smallrye-fault-tolerance",
"smallrye-health",
"smallrye-jwt",
"smallrye-metrics",
"smallrye-openapi",
"smallrye-reactive-messaging",
"smallrye-reactive-messaging-amqp",
"smallrye-reactive-messaging-kafka",
"smallrye-reactive-streams-operators",
"spring-data-jpa",
"spring-di",
"spring-web",
"spring-security",
"undertow",
"undertow-websockets",
"vertx"
};
static String applicationPropertiesContent = "# Configuration file\n" +
"# key = value\n" +
"\n" +
"# MP JWT\n" +
"mp.jwt.verify.publickey=asd\n" +
"mp.jwt.verify.publickey.location=/foo/bar\n" +
"\n" +
"quarkus.artemis.url=foo\n" +
"\n" +
"quarkus.oauth2.client-id=client_id\n" +
"quarkus.oauth2.client-secret=secret\n" +
"quarkus.oauth2.introspection-url=http://oauth-server/introspect";
static Map<String, Integer> generateProjectStatuses = new TreeMap<>();
static Map<String, Integer> compileProjectStatuses = new TreeMap<>();
static Map<String, Integer> testProjectStatuses = new TreeMap<>();
public static void main(String[] args) {
int arrayLength = extensions.length;
// for (int i = 1; i <= arrayLength; i++) {
// for (int i = 2; i <= 3; i++) {
// combinations(arrayLength, i);
// System.out.println(" === === === === === === ===");
// }
combinations(arrayLength, 3);
int numberOfFailures = 0;
for (Map.Entry<String, Integer> entry : generateProjectStatuses.entrySet()) {
numberOfFailures = numberOfFailures + entry.getValue() + compileProjectStatuses.get(entry.getKey()) + testProjectStatuses.get(entry.getKey());
System.out.println(entry.getKey() + "\t\t : " + entry.getValue().toString() +
"\t\t : " + compileProjectStatuses.get(entry.getKey()) +
"\t\t : " + testProjectStatuses.get(entry.getKey())
);
}
System.out.println("Number of failures: " + numberOfFailures);
if (numberOfFailures > 0) {
System.exit(1);
}
}
public static void combinations(int n, int r) {
int[] a = new int[r];
for (int i = 0; i < r; i++) { // initialize the first combination
a[i] = i;
}
int i = r - 1; // Index to keep track of maximum unsaturated element in array
// a[0] can only be n-r+1 exactly once - termination condition
while (a[0] < n - r + 1) {
// If outer elements are saturated
// keep decrementing i till you find unsaturated element
while (i > 0 && a[i] == n - r + i) {
i--;
}
processCombination(a);
a[i]++;
while (i < r - 1) { // Reset each outer element to prev element + 1
a[i + 1] = a[i] + 1;
i++;
}
}
}
private static void processCombination(int[] combination) {
StringBuilder artifactId = new StringBuilder("fooBar");
StringBuilder extensionsList = new StringBuilder();
for (int i = 0; i < combination.length ; i++) {
extensionsList.append(extensions[combination[i]]);
extensionsList.append(",");
artifactId.append("_");
artifactId.append(combination[i]);
}
String generateProjectCommand = "mvn io.quarkus:quarkus-maven-plugin:999-SNAPSHOT:create " +
"-DprojectGroupId=io.quarkus.qe -DprojectArtifactId=" + artifactId.toString() +
" -DprojectVersion=1.0.0-SNAPSHOT -DplatformArtifactId=quarkus-bom -DclassName=\"io.quarkus.qe.MyResource\"" +
" -Dextensions=\"" + extensionsList.toString() + "\"";
String compileProjectCommand = "mvn package -DskipTests -DskipITs -f " + artifactId.toString() + "/pom.xml";
String testProjectCommand = "mvn verify -f " + artifactId.toString() + "/pom.xml";
String cleanProjectCommand = "mvn clean -f " + artifactId.toString() + "/pom.xml";
executeCommandForArtifact(artifactId, generateProjectCommand, generateProjectStatuses,
Paths.get(artifactId.toString() + "-generateProjectStatuses.log"));
writeApplicationProperties(Paths.get(artifactId.toString() + "/src/main/resources/application.properties"));
executeCommandForArtifact(artifactId, compileProjectCommand, compileProjectStatuses,
Paths.get(artifactId.toString() + "-compileProjectStatuses.log"));
executeCommandForArtifact(artifactId, testProjectCommand, testProjectStatuses,
Paths.get(artifactId.toString() + "-testProjectStatuses.log"));
executeCommand(cleanProjectCommand);
}
private static void writeApplicationProperties(Path path) {
try {
Files.write(path, applicationPropertiesContent.getBytes(StandardCharsets.UTF_8));
} catch (IOException e) {
e.printStackTrace();
}
}
private static void executeCommandForArtifact(StringBuilder artifactId, String command, Map<String, Integer> commandStatuses, Path logPath) {
System.out.println(command);
try {
ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.command("bash", "-c", command);
Process mvnGenerateProcess = processBuilder.start();
BufferedReader reader = new BufferedReader(new InputStreamReader(mvnGenerateProcess.getInputStream()));
String line;
StringBuilder sb = new StringBuilder();
sb.append(command);
sb.append("\n\n");
while ((line = reader.readLine()) != null) {
sb.append(line);
sb.append("\n");
}
Files.write(logPath, sb.toString().getBytes(StandardCharsets.UTF_8));
int exitCode = mvnGenerateProcess.waitFor();
commandStatuses.put(artifactId.toString(), exitCode);
System.out.println("\tExited with error code: " + exitCode);
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
private static void executeCommand(String command) {
try {
ProcessBuilder processBuilder = new ProcessBuilder("bash", "-c", command);
Process process = processBuilder.start();
int exitCode = process.waitFor();
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
}