Skip to content
Merged
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 @@ -20,7 +20,6 @@

import org.apache.avro.Protocol;
import org.apache.avro.compiler.specific.SpecificCompiler;
import org.apache.avro.generic.GenericData;
import org.apache.avro.idl.IdlFile;
import org.apache.avro.idl.IdlReader;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
Expand Down Expand Up @@ -97,19 +96,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
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public void testIdlProtocolMojo() throws Exception {
assertFilesExist(outputDir, generatedFiles);

final String idlUserContent = FileUtils.fileRead(new File(outputDir, "IdlUser.java"));
assertTrue(idlUserContent.contains("java.time.Instant"));
assertTrue(idlUserContent.contains("@org.jetbrains.annotations.Nullable\n public java.lang.String getId"));
assertTrue(idlUserContent.contains("@org.jetbrains.annotations.NotNull\n public java.time.Instant getModifiedOn"));

assertEquals(Collections.singletonList("[WARN] Line 22, char 1: Ignoring out-of-place documentation comment.\n"
+ "Did you mean to use a multiline comment ( /* ... */ ) instead?"), log.getLogEntries());
Expand Down
1 change: 1 addition & 0 deletions lang/java/maven-plugin/src/test/resources/unit/idl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<sourceDirectory>${basedir}/src/test</sourceDirectory>
<outputDirectory>${basedir}/target/test-harness/idl</outputDirectory>
<stringType>String</stringType>
<createNullSafeAnnotations>true</createNullSafeAnnotations>
<project implementation="org.apache.maven.plugin.testing.stubs.MavenProjectStub"/>
</configuration>
</plugin>
Expand Down