Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVRO-4098: [maven-plugin]: make protocol-idl mojo support all compiler options [AVRO-4098] #3261

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,7 @@ protected void doCompile(File sourceFileForModificationDetection, Protocol proto
doCompile(sourceFileForModificationDetection, new SpecificCompiler(protocol), outputDirectory);
}

private void doCompile(File sourceFileForModificationDetection, SpecificCompiler compiler, File outputDirectory)
throws IOException {
protected void setCompilerProperties(SpecificCompiler compiler) {
compiler.setTemplateDir(templateDirectory);
compiler.setStringType(GenericData.StringType.valueOf(stringType));
compiler.setFieldVisibility(getFieldVisibility());
Expand All @@ -406,17 +405,22 @@ private void doCompile(File sourceFileForModificationDetection, SpecificCompiler
compiler.setCreateSetters(createSetters);
compiler.setCreateNullSafeAnnotations(createNullSafeAnnotations);
compiler.setEnableDecimalLogicalType(enableDecimalLogicalType);
compiler.setOutputCharacterEncoding(project.getProperties().getProperty("project.build.sourceEncoding"));
compiler.setAdditionalVelocityTools(instantiateAdditionalVelocityTools());
compiler.setRecordSpecificClass(this.recordSpecificClass);
compiler.setErrorSpecificClass(this.errorSpecificClass);
}

private void doCompile(File sourceFileForModificationDetection, SpecificCompiler compiler, File outputDirectory)
throws IOException {
setCompilerProperties(compiler);
try {
for (String customConversion : customConversions) {
compiler.addCustomConversion(Thread.currentThread().getContextClassLoader().loadClass(customConversion));
}
} catch (ClassNotFoundException e) {
throw new IOException(e);
}
compiler.setOutputCharacterEncoding(project.getProperties().getProperty("project.build.sourceEncoding"));
compiler.setAdditionalVelocityTools(instantiateAdditionalVelocityTools());
compiler.setRecordSpecificClass(this.recordSpecificClass);
compiler.setErrorSpecificClass(this.errorSpecificClass);
compiler.compileToDestination(sourceFileForModificationDetection, outputDirectory);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,10 @@ protected void doCompile(String filename, File sourceDirectory, File outputDirec
} else {
compiler = new SpecificCompiler(idlFile.getNamedSchemas().values());
}
compiler.setStringType(GenericData.StringType.valueOf(stringType));
compiler.setTemplateDir(templateDirectory);
compiler.setFieldVisibility(getFieldVisibility());
compiler.setCreateOptionalGetters(createOptionalGetters);
compiler.setGettersReturnOptional(gettersReturnOptional);
compiler.setOptionalGettersForNullableFieldsOnly(optionalGettersForNullableFieldsOnly);
compiler.setCreateSetters(createSetters);
compiler.setAdditionalVelocityTools(instantiateAdditionalVelocityTools());
compiler.setEnableDecimalLogicalType(enableDecimalLogicalType);
setCompilerProperties(compiler);
for (String customConversion : customConversions) {
compiler.addCustomConversion(projPathLoader.loadClass(customConversion));
}
compiler.setOutputCharacterEncoding(project.getProperties().getProperty("project.build.sourceEncoding"));
compiler.compileToDestination(sourceFilePath.toFile(), outputDirectory);
} finally {
Thread.currentThread().setContextClassLoader(contextClassLoader);
Expand Down
Loading