Skip to content

Commit

Permalink
Fixed the path to the extension catalog json for the all-config gen
Browse files Browse the repository at this point in the history
  • Loading branch information
aloubyansky committed May 5, 2021
1 parent bced3ac commit cfcd20b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 31 deletions.
3 changes: 1 addition & 2 deletions docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2608,8 +2608,7 @@
<skip>${skipDocs}</skip>
<mainClass>io.quarkus.docs.generation.AllConfigGenerator</mainClass>
<arguments>
<argument>${project.version}</argument>
<argument>${project.basedir}/../devtools/platform-descriptor-json/target/classes/quarkus-bom-descriptor/extensions.json</argument>
<argument>${project.basedir}/../devtools/bom-descriptor-json/target/quarkus-bom-quarkus-platform-descriptor-${project.version}-${project.version}.json</argument>
</arguments>
<environmentVariables>
<MAVEN_CMD_LINE_ARGS>${env.MAVEN_CMD_LINE_ARGS}</MAVEN_CMD_LINE_ARGS>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import io.quarkus.annotation.processor.generate_doc.ConfigDocSection;
import io.quarkus.annotation.processor.generate_doc.ConfigDocWriter;
import io.quarkus.annotation.processor.generate_doc.DocGeneratorUtil;
import io.quarkus.bootstrap.resolver.maven.BootstrapMavenException;
import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver;
import io.quarkus.maven.ArtifactCoords;
import io.quarkus.registry.catalog.Extension;
Expand All @@ -41,20 +40,18 @@ public static Artifact toAetherArtifact(ArtifactCoords coords) {
coords.getVersion());
}

public static void main(String[] args) throws BootstrapMavenException, IOException {
if (args.length != 2) {
public static void main(String[] args) throws Exception {
if (args.length != 1) {
// exit 1 will break Maven
throw new IllegalArgumentException("Usage: <version> <extension.json>");
throw new IllegalArgumentException("Usage: <extension-catalog.json>");
}
String version = args[0];
String extensionFile = args[1];
String jsonCatalog = args[0];

// This is where we produce the entire list of extensions
File jsonFile = new File(extensionFile);
File jsonFile = new File(jsonCatalog);
if (!jsonFile.exists()) {
System.err.println("WARNING: could not generate all-config file because extensions list is missing: " + jsonFile);
// exit 0 will break Maven
return;
throw new RuntimeException(
"Could not generate all-config file because extension catalog file is missing: " + jsonFile);
}
MavenArtifactResolver resolver = MavenArtifactResolver.builder().setWorkspaceDiscovery(false).build();

Expand All @@ -66,18 +63,16 @@ public static void main(String[] args) throws BootstrapMavenException, IOExcepti
Map<String, Extension> extensionsByGav = new HashMap<>();
Map<String, Extension> extensionsByConfigRoots = new HashMap<>();
for (Extension extension : extensionJson.getExtensions()) {
ArtifactRequest request = new ArtifactRequest();
Artifact artifact = toAetherArtifact(extension.getArtifact());
request.setArtifact(artifact);
requests.add(request);
final Artifact artifact = toAetherArtifact(extension.getArtifact());
requests.add(new ArtifactRequest().setArtifact(artifact));
// record the extension for this GAV
extensionsByGav.put(artifact.getGroupId() + ":" + artifact.getArtifactId(), extension);
}

// examine all the extension jars
List<ArtifactRequest> deploymentRequests = new ArrayList<>(extensionJson.getExtensions().size());
for (ArtifactResult result : resolver.resolve(requests)) {
Artifact artifact = result.getArtifact();
final Artifact artifact = result.getArtifact();
// which extension was this for?
Extension extension = extensionsByGav.get(artifact.getGroupId() + ":" + artifact.getArtifactId());
try (ZipFile zf = new ZipFile(artifact.getFile())) {
Expand All @@ -91,13 +86,11 @@ public static void main(String[] args) throws BootstrapMavenException, IOExcepti
new InputStreamReader(zf.getInputStream(entry), StandardCharsets.UTF_8))) {
Properties properties = new Properties();
properties.load(reader);
String deploymentGav = (String) properties.get("deployment-artifact");
final String deploymentCoords = (String) properties.get("deployment-artifact");
// if it has one, load it
if (deploymentGav != null) {
ArtifactRequest request = new ArtifactRequest();
Artifact deploymentArtifact = new DefaultArtifact(deploymentGav);
request.setArtifact(deploymentArtifact);
deploymentRequests.add(request);
if (deploymentCoords != null) {
final Artifact deploymentArtifact = toAetherArtifact(ArtifactCoords.fromString(deploymentCoords));
deploymentRequests.add(new ArtifactRequest().setArtifact(deploymentArtifact));
// tie this artifact to its extension
extensionsByGav.put(deploymentArtifact.getGroupId() + ":" + deploymentArtifact.getArtifactId(),
extension);
Expand All @@ -109,7 +102,7 @@ public static void main(String[] args) throws BootstrapMavenException, IOExcepti

// now examine all the extension deployment jars
for (ArtifactResult result : resolver.resolve(deploymentRequests)) {
Artifact artifact = result.getArtifact();
final Artifact artifact = result.getArtifact();
// which extension was this for?
Extension extension = extensionsByGav.get(artifact.getGroupId() + ":" + artifact.getArtifactId());
try (ZipFile zf = new ZipFile(artifact.getFile())) {
Expand All @@ -119,22 +112,21 @@ public static void main(String[] args) throws BootstrapMavenException, IOExcepti
}

// load all the config items per config root
ConfigDocItemScanner configDocItemScanner = new ConfigDocItemScanner();
Map<String, List<ConfigDocItem>> docItemsByConfigRoots = configDocItemScanner
final ConfigDocItemScanner configDocItemScanner = new ConfigDocItemScanner();
final Map<String, List<ConfigDocItem>> docItemsByConfigRoots = configDocItemScanner
.loadAllExtensionsConfigurationItems();
Map<String, String> artifactIdsByName = new HashMap<>();
final Map<String, String> artifactIdsByName = new HashMap<>();
ConfigDocWriter configDocWriter = new ConfigDocWriter();

// build a list of sorted config items by extension
List<ConfigDocItem> allItems = new ArrayList<>();
SortedMap<String, List<ConfigDocItem>> sortedConfigItemsByExtension = new TreeMap<>();

// Temporary fix for https://github.com/quarkusio/quarkus/issues/5214 until we figure out how to fix it
Extension openApi = extensionsByGav.get("io.quarkus:quarkus-smallrye-openapi");
if (openApi != null) {
extensionsByConfigRoots.put("io.quarkus.smallrye.openapi.common.deployment.SmallRyeOpenApiConfig", openApi);
}

// build a list of sorted config items by extension
final SortedMap<String, List<ConfigDocItem>> sortedConfigItemsByExtension = new TreeMap<>();

// sort extensions by name, assign their config items based on their config roots
for (Entry<String, Extension> entry : extensionsByConfigRoots.entrySet()) {
List<ConfigDocItem> items = docItemsByConfigRoots.get(entry.getKey());
Expand Down Expand Up @@ -163,6 +155,7 @@ public static void main(String[] args) throws BootstrapMavenException, IOExcepti
}

// now we have all the config items sorted by extension, let's build the entire list
final List<ConfigDocItem> allItems = new ArrayList<>();
for (Map.Entry<String, List<ConfigDocItem>> entry : sortedConfigItemsByExtension.entrySet()) {
final List<ConfigDocItem> configDocItems = entry.getValue();
// sort the items
Expand Down

0 comments on commit cfcd20b

Please sign in to comment.