Skip to content

Commit

Permalink
A bit of javadoc for codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
aloubyansky committed Mar 17, 2023
1 parent b2ce4c7 commit c4a14ae
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

import io.quarkus.bootstrap.model.ApplicationModel;

/**
* Code generation context
*/
public class CodeGenContext {
private final ApplicationModel model;
private final Path outDir;
Expand All @@ -15,6 +18,17 @@ public class CodeGenContext {
private final Config config;
private final boolean test;

/**
* Creates a code generation context
*
* @param model application model
* @param outDir target directory for the generated output
* @param workDir working directory, typically the main build directory of the project
* @param inputDir directory containing input content for a code generator
* @param redirectIO whether the code generating process should redirect its IO
* @param config application build time configuration
* @param test indicates whether the code generation is being triggered for tests
*/
public CodeGenContext(ApplicationModel model, Path outDir, Path workDir, Path inputDir, boolean redirectIO,
Config config, boolean test) {
this.model = model;
Expand All @@ -26,30 +40,65 @@ public CodeGenContext(ApplicationModel model, Path outDir, Path workDir, Path in
this.test = test;
}

/**
* Application model
*
* @return application model
*/
public ApplicationModel applicationModel() {
return model;
}

/**
* Target directory for the generated output
*
* @return target directory for the generated output
*/
public Path outDir() {
return outDir;
}

/**
* Working directory, typically the main build directory of the project
*
* @return working directory, typically the main build directory of the project
*/
public Path workDir() {
return workDir;
}

/**
* Directory containing input content for a code generator
*
* @return directory containing input content a code generator
*/
public Path inputDir() {
return inputDir;
}

/**
* Whether the code generation process should redirect its IO
*
* @return whether the code generation process should redirect its IO
*/
public boolean shouldRedirectIO() {
return redirectIO;
}

/**
* Application build time configuration
*
* @return application build time configuration
*/
public Config config() {
return config;
}

/**
* Indicates whether the code generation is being triggered for tests
*
* @return indicates whether the code generation is being triggered for tests
*/
public boolean test() {
return test;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ public interface CodeGenProvider {
String inputExtension();

/**
* Name of the directory containing the input files for the CodeGenProvider
* for <code>foo</code>, <code>src/main/foo</code> for application and <code>src/test/foo</code> for test resources
* Name of the directory containing input files for a given {@link CodeGenProvider} implementation
* relative to a sources root directory. For example, if an input directory is configured as <code>foo</code>,
* for a production build of an application the sources will be looked up at <code>src/main/foo</code> path
* and at <code>src/test/foo</code> for tests.
*
* @return the input directory
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,33 @@

import io.quarkus.deployment.CodeGenProvider;

/**
* Links a {@link CodeGenProvider} instance, an input and output directories for the provider.
*/
public class CodeGenData {
public final CodeGenProvider provider;
public final Path outPath;
public final Path sourceDir;
public final Path buildDir;
public boolean redirectIO;

/**
* @param provider code gen provider
* @param outPath where the generated output should be stored
* @param sourceDir where the input sources are
* @param buildDir base project output directory
*/
public CodeGenData(CodeGenProvider provider, Path outPath, Path sourceDir, Path buildDir) {
this(provider, outPath, sourceDir, buildDir, true);
}

/**
* @param provider code gen provider
* @param outPath where the generated output should be stored
* @param sourceDir where the input sources are
* @param buildDir base project output directory
* @param redirectIO whether to redirect IO, in case a provider is logging something
*/
public CodeGenData(CodeGenProvider provider, Path outPath, Path sourceDir, Path buildDir, boolean redirectIO) {
this.provider = provider;
this.outPath = outPath;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.quarkus.bootstrap.model;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
Expand All @@ -13,31 +12,85 @@
import io.quarkus.maven.dependency.Dependency;
import io.quarkus.maven.dependency.ResolvedDependency;

/**
* Application dependency model. Allows to explore application dependencies,
* Quarkus platforms found in the project configuration and Quarkus platform configuration properties.
*/
public interface ApplicationModel {

/**
* Main application artifact
*
* @return main application artifact
*/
ResolvedDependency getAppArtifact();

/**
* All the dependencies of an application including runtime and build time dependencies.
*
* @return application runtime and build time dependencies
*/
Collection<ResolvedDependency> getDependencies();

/**
* Runtime dependencies of an application
*
* @return runtime dependencies of an application
*/
default Collection<ResolvedDependency> getRuntimeDependencies() {
return getDependencies().stream().filter(Dependency::isRuntimeCp).collect(Collectors.toList());
}

/**
* Quarkus platforms (BOMs) found in the configuration of an application
*
* @return Quarkus platforms (BOMs) found in the configuration of an application
*/
PlatformImports getPlatforms();

/**
* Quarkus platform configuration properties
*
* @return Quarkus platform configuration properties
*/
default Map<String, String> getPlatformProperties() {
final PlatformImports platformImports = getPlatforms();
return platformImports == null ? Collections.emptyMap() : platformImports.getPlatformProperties();
return platformImports == null ? Map.of() : platformImports.getPlatformProperties();
}

/**
* Extension capability requirements collected from the extensions found on the classpath of an application
*
* @return Extension capability requirements collected from the extensions found on the classpath of an application
*/
Collection<ExtensionCapabilities> getExtensionCapabilities();

/**
* Class loading parent-first artifacts
*
* @return class loading parent-first artifacts
*/
Set<ArtifactKey> getParentFirst();

/**
* Class loading runner parent-first artifacts
*
* @return class loading runner parent-first artifacts
*/
Set<ArtifactKey> getRunnerParentFirst();

/**
* Class loading lower priority artifacts
*
* @return class loading lower priority artifacts
*/
Set<ArtifactKey> getLowerPriorityArtifacts();

/**
* Local project dependencies that are live-reloadable in dev mode.
*
* @return local project dependencies that are live-reloadable in dev mode.
*/
Set<ArtifactKey> getReloadableWorkspaceDependencies();

/**
Expand All @@ -47,10 +100,20 @@ default Map<String, String> getPlatformProperties() {
*/
Map<ArtifactKey, Set<String>> getRemovedResources();

/**
* Main workspace module of an application. Could be null, in case the project is not available during the build.
*
* @return main workspace module of an application, could be null, in case the project is not available during the build
*/
default WorkspaceModule getApplicationModule() {
return getAppArtifact().getWorkspaceModule();
}

/**
* All the workspace modules found as dependencies of an application
*
* @return all the workspace modules found as dependencies of an application
*/
default Collection<WorkspaceModule> getWorkspaceModules() {
final Map<WorkspaceModuleId, WorkspaceModule> result = new HashMap<>();
collectModules(getAppArtifact().getWorkspaceModule(), result);
Expand Down

0 comments on commit c4a14ae

Please sign in to comment.