Skip to content

Commit a283a82

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

File tree

2 files changed

+60
-44
lines changed

2 files changed

+60
-44
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 {
@@ -202,7 +204,7 @@ private void doGenerate() throws ProvisioningException {
202204
if (Files.exists(home.resolve(WfConstants.STANDALONE).resolve(WfConstants.CONFIGURATION))) {
203205
standaloneFeatures = readFeatureSpecs(createStandaloneServer(installation, mimimumStability, null));
204206
Boolean all = Boolean.getBoolean("org.wildfly.galleon.complete.model");
205-
ModelNode result = generateModel(createStandaloneServer(installation, mimimumStability, all ? "standalone.xml" : "standalone-local.xml"), all);
207+
ModelNode result = generateModel(createStandaloneServer(installation, mimimumStability, all ? "standalone.xml" : "standalone-local.xml"), all, description);
206208
try {
207209
if (!Files.exists(outputDir)) {
208210
Files.createDirectories(outputDir);
@@ -248,17 +250,18 @@ private void doGenerate() throws ProvisioningException {
248250

249251
@Override
250252
public void forkedForEmbedded(String... args) throws ConfigGeneratorException {
251-
if (args.length != 3 && args.length != 4) {
253+
if(args.length != 4 && args.length != 5) {
252254
final StringBuilder buf = new StringBuilder();
253255
StringUtils.append(buf, Arrays.asList(args));
254-
throw new IllegalArgumentException("Expected 3-4 arguments but got " + Arrays.asList(args));
256+
throw new IllegalArgumentException("Expected 4-5 arguments but got " + Arrays.asList(args));
255257
}
256258
try {
257-
String mimimumStability = args.length == 4 ? args[3] : null;
259+
String description = args.length > 3 ? args[3] : null;
260+
String mimimumStability = args.length == 5 ? args[4] : null;
258261
ModelNode result = readFeatureSpecs(createStandaloneServer(args[0], mimimumStability, null));
259262
writeSpecsFile(Paths.get(args[1]), result);
260263
Boolean all = Boolean.getBoolean("org.wildfly.galleon.complete.model");
261-
ModelNode resultModel = generateModel(createStandaloneServer(args[0], mimimumStability, all ? "standalone.xml" : "standalone-local.xml"), all);
264+
ModelNode resultModel = generateModel(createStandaloneServer(args[0], mimimumStability, all ? "standalone.xml" : "standalone-local.xml"), all, description);
262265
writeModelFile(Paths.get(args[1]).toAbsolutePath().getParent().resolve("model.json"), resultModel);
263266
System.out.println("FORKED TO " + Paths.get(args[1]).toAbsolutePath().getParent().resolve("model.json"));
264267
if (Files.exists(Paths.get(args[0]).resolve(WfConstants.DOMAIN).resolve(WfConstants.CONFIGURATION))) {
@@ -346,37 +349,41 @@ private static String[] getCmdArgs(String mimimumStability, String serverConfig)
346349
return args.toArray(String[]::new);
347350
}
348351

349-
private static ModelNode generateModel(final EmbeddedManagedProcess server, Boolean all) throws ProvisioningException {
352+
private static ModelNode generateModel(final EmbeddedManagedProcess server, Boolean all, String description) throws ProvisioningException {
350353
try {
351354
server.start();
352355
if (!all) {
353-
return readModel(server);
356+
return readModel(server, description);
354357
}
355-
return readAll(server);
358+
return readAll(server, description);
356359
} catch (EmbeddedProcessStartException ex) {
357360
throw new ProvisioningException("Failed to read feature spec descriptions", ex);
358361
} finally {
359362
server.stop();
360363
}
361364
}
362365

363-
private static ModelNode readModel(final EmbeddedManagedProcess server) throws ProvisioningException {
366+
private static ModelNode readModel(final EmbeddedManagedProcess server, String description) throws ProvisioningException {
364367
List<String> subsystems = listSubsystems(server);
365-
ModelNode result = new ModelNode();
368+
ModelNode result = new ModelNode().setEmptyObject();
366369
ModelNode subsystemNodes = result.get("children").get(ClientConstants.SUBSYSTEM).get("model-description");
367-
for (String subsystem : subsystems) {
370+
for(String subsystem : subsystems) {
368371
ModelNode address = Operations.createAddress(ClientConstants.SUBSYSTEM, subsystem);
369-
ModelNode subsystemDescription = readResourceDescription(server, address);
372+
ModelNode subsystemDescription = readResourceDescription(server, address, true);
370373
subsystemDescription.get(ClientConstants.ADDRESS).add(address);
371374
subsystemNodes.get(subsystem).set(subsystemDescription);
372375
}
373376
ModelNode address = Operations.createAddress(ClientConstants.DEPLOYMENT);
374-
result.get("children").get(ClientConstants.DEPLOYMENT).get("model-description").get("*").set(readResourceDescription(server, address));
377+
result.get("children").get(ClientConstants.DEPLOYMENT).get("model-description").get("*").set(readResourceDescription(server, address, true));
375378
result.remove(ClientConstants.RESULT);
379+
ModelNode subsystemsDescription = readResourceDescription(server, Operations.createAddress().setEmptyList(), false);
380+
result.get("children").get(ClientConstants.SUBSYSTEM).get("description").set(subsystemsDescription.get("children").get(ClientConstants.SUBSYSTEM).get("description"));
381+
result.get("children").get(ClientConstants.DEPLOYMENT).get("description").set(subsystemsDescription.get("children").get(ClientConstants.DEPLOYMENT).get("description"));
382+
result.get("description").set(description);
376383
return result;
377384
}
378385

379-
private static ModelNode readAll(final EmbeddedManagedProcess server) throws ProvisioningException {
386+
private static ModelNode readAll(final EmbeddedManagedProcess server, String description) throws ProvisioningException {
380387
ModelNode rootAddress = Operations.createAddress().setEmptyList();
381388
final ModelNode op = Operations.createOperation("read-resource-description", rootAddress);
382389
op.get(ClientConstants.RECURSIVE).set(true);
@@ -389,7 +396,9 @@ private static ModelNode readAll(final EmbeddedManagedProcess server) throws Pro
389396
if (!Operations.isSuccessfulOutcome(result)) {
390397
throw new ProvisioningException(Operations.getFailureDescription(result).asString());
391398
}
392-
return result.get(ClientConstants.RESULT);
399+
final ModelNode effectiveResult = result.get(ClientConstants.RESULT);
400+
effectiveResult.get("description").set(description);
401+
return effectiveResult;
393402
}
394403

395404
private static List<String> listSubsystems(final EmbeddedManagedProcess server) throws ProvisioningException {
@@ -413,9 +422,9 @@ private static List<String> listSubsystems(final EmbeddedManagedProcess server)
413422
return names;
414423
}
415424

416-
private static ModelNode readResourceDescription(final EmbeddedManagedProcess server, ModelNode address) throws ProvisioningException {
425+
private static ModelNode readResourceDescription(final EmbeddedManagedProcess server, ModelNode address, boolean recursive) throws ProvisioningException {
417426
final ModelNode op = Operations.createOperation("read-resource-description", address);
418-
op.get(ClientConstants.RECURSIVE).set(true);
427+
op.get(ClientConstants.RECURSIVE).set(recursive);
419428
final ModelNode opResult;
420429
try {
421430
opResult = server.getModelControllerClient().execute(op);

maven-plugin/src/main/java/org/wildfly/galleon/maven/FeatureSpecGeneratorInvoker.java

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -102,28 +102,29 @@ public class FeatureSpecGeneratorInvoker {
102102
TASKS_XML_PATH_END = pmWf + File.separator + WfConstants.TASKS_XML;
103103
}
104104

105-
private MavenProject project;
106-
private MavenSession session;
107-
private List<RemoteRepository> repositories;
108-
private RepositorySystem repoSystem;
109-
private ArtifactResolver artifactResolver;
110-
private WildFlyFeaturePackBuild buildConfig;
111-
private Log log;
112-
113-
private File featureSpecsOutput;
114-
private boolean forkEmbedded;
115-
private Path wildflyHome;
116-
private Path moduleTemplatesDir;
117-
118-
private Map<String, Artifact> mergedArtifacts = new HashMap<>();
119-
private Map<String, Map<String, Artifact>> moduleTemplates = new HashMap<>();
105+
private final MavenProject project;
106+
private final MavenSession session;
107+
private final List<RemoteRepository> repositories;
108+
private final RepositorySystem repoSystem;
109+
private final ArtifactResolver artifactResolver;
110+
private final WildFlyFeaturePackBuild buildConfig;
111+
private final Log log;
112+
113+
private final File featureSpecsOutput;
114+
private final boolean forkEmbedded;
115+
private final Path wildflyHome;
116+
private final Path moduleTemplatesDir;
117+
118+
private final Map<String, Artifact> mergedArtifacts = new HashMap<>();
119+
private final Map<String, Map<String, Artifact>> moduleTemplates = new HashMap<>();
120120

121121
private Map<String, Path> inheritedFeatureSpecs = Collections.emptyMap();
122122
private Set<String> standaloneExtensions = Collections.emptySet();
123123
private Set<String> domainExtensions = Collections.emptySet();
124124
private Set<String> hostExtensions = Collections.emptySet();
125125
private List<Path> layersConfs = Collections.emptyList();
126-
private String minimumStabilityLevel;
126+
private final String minimumStabilityLevel;
127+
private final String description;
127128

128129
private WildFlyPackageTasksParser tasksParser;
129130
private ProvisioningLayoutFactory layoutFactory;
@@ -140,6 +141,7 @@ public class FeatureSpecGeneratorInvoker {
140141
this.wildflyHome = mojo.wildflyHome.toPath();
141142
this.moduleTemplatesDir = mojo.moduleTemplatesDir.toPath();
142143
this.minimumStabilityLevel = mojo.minimumStabilityLevel;
144+
this.description = this.project.getDescription() == null || this.project.getDescription().isBlank() ? this.project.getName() : this.project.getDescription();
143145
this.log = mojo.getLog();
144146
}
145147

@@ -490,7 +492,7 @@ private void processFeaturePackDep(MavenProjectArtifactVersions artifactVersions
490492
try(DirectoryStream<Path> stream = Files.newDirectoryStream(p)) {
491493
for(Path path : stream) {
492494
String specName = path.getFileName().toString();
493-
if(specName.charAt(specName.length() - 1) == '/') {
495+
if (specName.charAt(specName.length() - 1) == '/') {
494496
specName = specName.substring(0, specName.length() - 1);
495497
}
496498
path = path.resolve(Constants.SPEC_XML);
@@ -737,15 +739,20 @@ private void debug(String format, Object... args) {
737739
private Object getFeaturePackGenerator(Class<?> specGenCls) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
738740
debug("Creating a feature spec generator for stability %s using %s", minimumStabilityLevel, specGenCls);
739741
try {
740-
return specGenCls.getConstructor(String.class, Path.class, Map.class, String.class, boolean.class, boolean.class)
741-
.newInstance(wildflyHome.toString(), featureSpecsOutput.toPath(), inheritedFeatureSpecs, minimumStabilityLevel, forkEmbedded, log.isDebugEnabled());
742+
return specGenCls.getConstructor(String.class, Path.class, Map.class, String.class, String.class, boolean.class, boolean.class)
743+
.newInstance(wildflyHome.toString(), featureSpecsOutput.toPath(), inheritedFeatureSpecs, minimumStabilityLevel, description, forkEmbedded, log.isDebugEnabled());
742744
} catch (NoSuchMethodException e) {
743-
if (minimumStabilityLevel != null && !minimumStabilityLevel.isEmpty()) {
744-
return specGenCls.getConstructor(String.class, Path.class, Map.class, boolean.class, boolean.class)
745-
.newInstance(wildflyHome.toString(), featureSpecsOutput.toPath(), inheritedFeatureSpecs, forkEmbedded, log.isDebugEnabled());
746-
} else {
747-
// We've been configured to use a stability but the generator class does not support it
748-
throw e;
745+
try {
746+
return specGenCls.getConstructor(String.class, Path.class, Map.class, String.class, String.class, String.class, boolean.class, boolean.class)
747+
.newInstance(wildflyHome.toString(), featureSpecsOutput.toPath(), inheritedFeatureSpecs, minimumStabilityLevel, forkEmbedded, log.isDebugEnabled());
748+
} catch (NoSuchMethodException ex) {
749+
if (minimumStabilityLevel != null && !minimumStabilityLevel.isEmpty()) {
750+
return specGenCls.getConstructor(String.class, Path.class, Map.class, boolean.class, boolean.class)
751+
.newInstance(wildflyHome.toString(), featureSpecsOutput.toPath(), inheritedFeatureSpecs, forkEmbedded, log.isDebugEnabled());
752+
} else {
753+
// We've been configured to use a stability but the generator class does not support it
754+
throw ex;
755+
}
749756
}
750757
}
751758
}

0 commit comments

Comments
 (0)