Skip to content

Commit

Permalink
Support disabling default Java code generation
Browse files Browse the repository at this point in the history
  • Loading branch information
ascopes committed Dec 29, 2023
1 parent e02eab3 commit d7dedc6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,22 @@ public abstract class AbstractGenerateMojo extends AbstractMojo {
@Parameter(defaultValue = "false")
private boolean fatalWarnings;

/**
* Whether to generate default Java source code.
*
* <p>Defaults to true, although some users may wish to disable this if using
* an alternative plugin instead.
*
* @since 0.1.1
*/
@Parameter(defaultValue = "true")
private boolean javaEnabled;

/**
* Whether to also generate Kotlin API wrapper code around the generated Java code.
*
* <p>Note that this requires {@code javaEnabled} to also be {@code true}, otherwise compilation may fail.
*
* @since 0.1.0
*/
@Parameter(defaultValue = "false")
Expand Down Expand Up @@ -183,6 +196,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
.addAllAllowedDependencyScopes(allowedScopes())
.addAllSourceRoots(actualSourceDirectories)
.isFatalWarnings(fatalWarnings)
.isJavaEnabled(javaEnabled)
.isKotlinEnabled(kotlinEnabled)
.isLiteEnabled(liteOnly)
.mavenSession(session)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public interface GenerationRequest {

boolean isFatalWarnings();

boolean isJavaEnabled();

boolean isKotlinEnabled();

boolean isLiteEnabled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ public boolean generate(GenerationRequest request) throws ResolutionException, I
.fatalWarnings(request.isFatalWarnings())
.importPaths(importPaths)
.importPaths(request.getSourceRoots())
.plugins(plugins, request.getOutputDirectory())
.javaOut(request.getOutputDirectory(), request.isLiteEnabled());
.plugins(plugins, request.getOutputDirectory());

if (request.isJavaEnabled()) {
argLineBuilder.javaOut(request.getOutputDirectory(), request.isLiteEnabled());
}

if (request.isKotlinEnabled()) {
argLineBuilder.kotlinOut(request.getOutputDirectory(), request.isLiteEnabled());
Expand Down

0 comments on commit d7dedc6

Please sign in to comment.