Skip to content

Commit 0ae7105

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

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 {
@@ -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);

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)