Skip to content

Commit 1d6b998

Browse files
committed
Adding missing descriptions in top elements.
Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
1 parent 610036b commit 1d6b998

File tree

2 files changed

+129
-112
lines changed

2 files changed

+129
-112
lines changed

feature-spec-gen/src/main/java/org/wildfly/galleon/plugin/featurespec/generator/FeatureSpecGenerator.java

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public class FeatureSpecGenerator implements ForkCallback {
7474
private Path standaloneSpecsFile;
7575
private Path domainSpecsFile;
7676
private String mimimumStability;
77+
private String description;
7778

7879
String getBranchId(String spec, int dots) {
7980
int i = 0;
@@ -141,13 +142,14 @@ public FeatureSpecGenerator() {
141142
}
142143

143144
public FeatureSpecGenerator(String installation, Path outputDir, Map<String, Path> inheritedSpecs,
144-
String mimimumStability, boolean fork, boolean debug) {
145+
String mimimumStability, String description, boolean fork, boolean debug) {
145146
this.installation = installation;
146147
this.outputDir = outputDir;
147148
this.fork = fork;
148149
this.debug = debug;
149150
this.inheritedSpecs = inheritedSpecs;
150151
this.mimimumStability = mimimumStability;
152+
this.description = description == null ? "" : description;
151153
}
152154

153155
public int generateSpecs() throws ProvisioningException {
@@ -185,7 +187,7 @@ private void doGenerate() throws ProvisioningException {
185187
ModelNode domainRoots = null;
186188
if (fork) {
187189
String minStab = mimimumStability == null ? "" : mimimumStability;
188-
ForkedEmbeddedUtil.fork(this, getStoredSystemProps(), installation, getStandaloneSpecsFile().toString(), getDomainSpecsFile().toString(), minStab);
190+
ForkedEmbeddedUtil.fork(this, getStoredSystemProps(), installation, getStandaloneSpecsFile().toString(), getDomainSpecsFile().toString(), description , minStab);
189191
standaloneFeatures = readSpecsFile(getStandaloneSpecsFile());
190192
Path model = getStandaloneSpecsFile().getParent().resolve("model.json");
191193
try {
@@ -201,7 +203,7 @@ private void doGenerate() throws ProvisioningException {
201203
final Path home = Paths.get(installation);
202204
if (Files.exists(home.resolve(WfConstants.STANDALONE).resolve(WfConstants.CONFIGURATION))) {
203205
standaloneFeatures = readFeatureSpecs(createStandaloneServer(installation, mimimumStability, null));
204-
ModelNode result = generateModel(createStandaloneServer(installation, mimimumStability, "standalone-local.xml"));
206+
ModelNode result = generateModel(createStandaloneServer(installation, mimimumStability, "standalone-local.xml"), description);
205207
try {
206208
if (!Files.exists(outputDir)) {
207209
Files.createDirectories(outputDir);
@@ -247,16 +249,17 @@ private void doGenerate() throws ProvisioningException {
247249

248250
@Override
249251
public void forkedForEmbedded(String... args) throws ConfigGeneratorException {
250-
if (args.length != 3 && args.length != 4) {
252+
if(args.length != 4 && args.length != 5) {
251253
final StringBuilder buf = new StringBuilder();
252254
StringUtils.append(buf, Arrays.asList(args));
253-
throw new IllegalArgumentException("Expected 3-4 arguments but got " + Arrays.asList(args));
255+
throw new IllegalArgumentException("Expected 4-5 arguments but got " + Arrays.asList(args));
254256
}
255257
try {
256-
String mimimumStability = args.length == 4 ? args[3] : null;
258+
String description = args.length > 3 ? args[3] : null;
259+
String mimimumStability = args.length == 5 ? args[4] : null;
257260
ModelNode result = readFeatureSpecs(createStandaloneServer(args[0], mimimumStability, null));
258261
writeSpecsFile(Paths.get(args[1]), result);
259-
ModelNode resultModel = generateModel(createStandaloneServer(args[0], mimimumStability, "standalone-local.xml"));
262+
ModelNode resultModel = generateModel(createStandaloneServer(args[0], mimimumStability, "standalone-local.xml"), description);
260263
writeModelFile(Paths.get(args[1]).toAbsolutePath().getParent().resolve("model.json"), resultModel);
261264
System.out.println("FORKED TO " + Paths.get(args[1]).toAbsolutePath().getParent().resolve("model.json"));
262265
if (Files.exists(Paths.get(args[0]).resolve(WfConstants.DOMAIN).resolve(WfConstants.CONFIGURATION))) {
@@ -344,38 +347,42 @@ private static String[] getCmdArgs(String mimimumStability, String serverConfig)
344347
return args.toArray(String[]::new);
345348
}
346349

347-
private static ModelNode generateModel(final EmbeddedManagedProcess server) throws ProvisioningException {
350+
private static ModelNode generateModel(final EmbeddedManagedProcess server, String description) throws ProvisioningException {
348351
try {
349352
server.start();
350353
Boolean all = Boolean.getBoolean("org.wildfly.galleon.complete.model");
351354
if (!all) {
352-
return readModel(server);
355+
return readModel(server, description);
353356
}
354-
return readAll(server);
357+
return readAll(server, description);
355358
} catch (EmbeddedProcessStartException ex) {
356359
throw new ProvisioningException("Failed to read feature spec descriptions", ex);
357360
} finally {
358361
server.stop();
359362
}
360363
}
361364

362-
private static ModelNode readModel(final EmbeddedManagedProcess server) throws ProvisioningException {
365+
private static ModelNode readModel(final EmbeddedManagedProcess server, String description) throws ProvisioningException {
363366
List<String> subsystems = listSubsystems(server);
364-
ModelNode result = new ModelNode();
367+
ModelNode result = new ModelNode().setEmptyObject();
365368
ModelNode subsystemNodes = result.get("children").get(ClientConstants.SUBSYSTEM).get("model-description");
366-
for (String subsystem : subsystems) {
369+
for(String subsystem : subsystems) {
367370
ModelNode address = Operations.createAddress(ClientConstants.SUBSYSTEM, subsystem);
368-
ModelNode subsystemDescription = readResourceDescription(server, address);
371+
ModelNode subsystemDescription = readResourceDescription(server, address, true);
369372
subsystemDescription.get(ClientConstants.ADDRESS).add(address);
370373
subsystemNodes.get(subsystem).set(subsystemDescription);
371374
}
372375
ModelNode address = Operations.createAddress(ClientConstants.DEPLOYMENT);
373-
result.get("children").get(ClientConstants.DEPLOYMENT).get("model-description").get("*").set(readResourceDescription(server, address));
376+
result.get("children").get(ClientConstants.DEPLOYMENT).get("model-description").get("*").set(readResourceDescription(server, address, true));
374377
result.remove(ClientConstants.RESULT);
378+
ModelNode subsystemsDescription = readResourceDescription(server, Operations.createAddress().setEmptyList(), false);
379+
result.get("children").get(ClientConstants.SUBSYSTEM).get("description").set(subsystemsDescription.get("children").get(ClientConstants.SUBSYSTEM).get("description"));
380+
result.get("children").get(ClientConstants.DEPLOYMENT).get("description").set(subsystemsDescription.get("children").get(ClientConstants.DEPLOYMENT).get("description"));
381+
result.get("description").set(description);
375382
return result;
376383
}
377384

378-
private static ModelNode readAll(final EmbeddedManagedProcess server) throws ProvisioningException {
385+
private static ModelNode readAll(final EmbeddedManagedProcess server, String description) throws ProvisioningException {
379386
ModelNode rootAddress = Operations.createAddress().setEmptyList();
380387
final ModelNode op = Operations.createOperation("read-resource-description", rootAddress);
381388
op.get(ClientConstants.RECURSIVE).set(true);
@@ -388,7 +395,9 @@ private static ModelNode readAll(final EmbeddedManagedProcess server) throws Pro
388395
if (!Operations.isSuccessfulOutcome(result)) {
389396
throw new ProvisioningException(Operations.getFailureDescription(result).asString());
390397
}
391-
return result.get(ClientConstants.RESULT);
398+
final ModelNode effectiveResult = result.get(ClientConstants.RESULT);
399+
effectiveResult.get("description").set(description);
400+
return effectiveResult;
392401
}
393402

394403
private static List<String> listSubsystems(final EmbeddedManagedProcess server) throws ProvisioningException {
@@ -412,9 +421,9 @@ private static List<String> listSubsystems(final EmbeddedManagedProcess server)
412421
return names;
413422
}
414423

415-
private static ModelNode readResourceDescription(final EmbeddedManagedProcess server, ModelNode address) throws ProvisioningException {
424+
private static ModelNode readResourceDescription(final EmbeddedManagedProcess server, ModelNode address, boolean recursive) throws ProvisioningException {
416425
final ModelNode op = Operations.createOperation("read-resource-description", address);
417-
op.get(ClientConstants.RECURSIVE).set(true);
426+
op.get(ClientConstants.RECURSIVE).set(recursive);
418427
final ModelNode opResult;
419428
try {
420429
opResult = server.getModelControllerClient().execute(op);

0 commit comments

Comments
 (0)