Class SchemaCompileMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.spf4j.maven.plugin.avro.avscp.SchemaCompileMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="avro-compile", defaultPhase=GENERATE_SOURCES, requiresDependencyResolution=COMPILE_PLUS_RUNTIME) public final class SchemaCompileMojo extends org.apache.maven.plugin.AbstractMojoMojo that will compile the avro sources: *.avsc, *.avpr, *.avdl in: 1) java files. 2) avsc files.- Author:
- Zoltan Farkas
-
-
Field Summary
Fields Modifier and Type Field Description protected FiledependenciesDirectoryThe directory where all schema dependencies (avsc, avpr, avdl) are made vailableprotected FilegeneratedAvscTargetthe destination for the generated avro schema json files (will be published along with the java code).protected FilegeneratedJavaTargetthe destination for the java generated files.protected org.apache.maven.project.MavenProjectmavenProjectprotected org.apache.maven.execution.MavenSessionmavenSessionThe current build mavenSession instance.protected org.eclipse.aether.RepositorySystemrepoSystemThe entry point to Aether, i.e.static StringSCHEMA_INDEX_FILENAMEstatic StringSCHEMA_INDEX_PGK_KEYstatic StringSCHEMA_MANIFESTprotected StringschemaArtifactClassifierthe schema artifact classifier.protected StringschemaArtifactExtensionthe schema artifact extension.protected FilesourceDirectoryThe source directory of avro files.protected Filetargetthe target folder.protected booleanuseSchemaReferencesForAvscThis option will use schema references when writing schemas that depend of schemas from other projects, instead of baking them in.
-
Constructor Summary
Constructors Constructor Description SchemaCompileMojo()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMvnIdToIdlsAndMoveToDestination(Path destPath)voidcompileAvpr(Path pSources)voidcompileIdl(Path pSources)List<URL>createPathUrls(File sourceFolder)voiddeleteGeneratedAvailableInDependencies()voiddeleteProtocolClasses()voiddeleteSchemasAvailableInDependencies(Path schTargetPath)protected voiddoCompileIDL(File sourceDir, String filename)protected voiddoCompileProtocol(String filename, Path destination)protected voiddoCompileSchemas(String[] filenames)voidexecute()Children must call this.StringgenMnvId(Schema schema)static String[]getFiles(File directory, String pattern)FilegetGeneratedAvscTarget()org.apache.maven.project.MavenProjectgetMavenProject()org.apache.maven.execution.MavenSessiongetMavenSession()CharSequencegetPackageMvnIdPrefix()org.eclipse.aether.RepositorySystemgetRepoSystem()String[]getSourceFiles(String pattern)FilegetTarget()StringtoString()will be overwritten as needed, and override will include this result.
-
-
-
Field Detail
-
SCHEMA_INDEX_FILENAME
public static final String SCHEMA_INDEX_FILENAME
- See Also:
- Constant Field Values
-
SCHEMA_INDEX_PGK_KEY
public static final String SCHEMA_INDEX_PGK_KEY
- See Also:
- Constant Field Values
-
SCHEMA_MANIFEST
public static final String SCHEMA_MANIFEST
- See Also:
- Constant Field Values
-
mavenProject
@Parameter(defaultValue="${project}", required=true, readonly=true) protected org.apache.maven.project.MavenProject mavenProject
-
dependenciesDirectory
@Parameter(name="dependenciesDirectory", defaultValue="${project.build.directory}/schema-dependencies", readonly=true) protected File dependenciesDirectoryThe directory where all schema dependencies (avsc, avpr, avdl) are made vailable
-
sourceDirectory
@Parameter(name="sourceDirectory", defaultValue="${basedir}/src/main/avro") protected File sourceDirectoryThe source directory of avro files. This directory is added to the classpath at schema compiling time. All files can therefore be referenced as classpath resources following the directory structure under the source directory.
-
generatedJavaTarget
@Parameter(name="generatedJavaTarget", defaultValue="${project.build.directory}/generated-sources/avro") protected File generatedJavaTargetthe destination for the java generated files.
-
generatedAvscTarget
@Parameter(name="generatedAvscTarget", defaultValue="${project.build.directory}/generated-sources/avsc") protected File generatedAvscTargetthe destination for the generated avro schema json files (will be published along with the java code).
-
target
@Parameter(name="target", defaultValue="${project.build.directory}") protected File targetthe target folder.
-
mavenSession
@Parameter(defaultValue="${session}", required=true, readonly=true) protected org.apache.maven.execution.MavenSession mavenSessionThe current build mavenSession instance.
-
useSchemaReferencesForAvsc
@Parameter(name="useSchemaReferencesForAvsc", defaultValue="false") protected boolean useSchemaReferencesForAvscThis option will use schema references when writing schemas that depend of schemas from other projects, instead of baking them in. by default (false) all schema references will be inlined.
-
schemaArtifactClassifier
@Parameter(name="schemaArtifactClassifier", defaultValue="avsc") protected String schemaArtifactClassifierthe schema artifact classifier.
-
schemaArtifactExtension
@Parameter(name="schemaArtifactExtension", defaultValue="jar") protected String schemaArtifactExtensionthe schema artifact extension.
-
repoSystem
@Component protected org.eclipse.aether.RepositorySystem repoSystem
The entry point to Aether, i.e. the component doing all the work.
-
-
Method Detail
-
getPackageMvnIdPrefix
public CharSequence getPackageMvnIdPrefix()
-
doCompileIDL
protected void doCompileIDL(File sourceDir, String filename) throws IOException
- Throws:
IOException
-
createPathUrls
public List<URL> createPathUrls(File sourceFolder) throws MalformedURLException, org.apache.maven.artifact.DependencyResolutionRequiredException
- Throws:
MalformedURLExceptionorg.apache.maven.artifact.DependencyResolutionRequiredException
-
doCompileSchemas
protected void doCompileSchemas(String[] filenames) throws IOException
- Throws:
IOException
-
doCompileProtocol
protected void doCompileProtocol(String filename, Path destination) throws IOException
- Throws:
IOException
-
deleteGeneratedAvailableInDependencies
public void deleteGeneratedAvailableInDependencies() throws IOException- Throws:
IOException
-
deleteProtocolClasses
public void deleteProtocolClasses() throws IOException- Throws:
IOException
-
deleteSchemasAvailableInDependencies
public void deleteSchemasAvailableInDependencies(Path schTargetPath) throws IOException
- Throws:
IOException
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionChildren must call this.- Specified by:
executein interfaceorg.apache.maven.plugin.Mojo- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
compileIdl
public void compileIdl(Path pSources) throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
addMvnIdToIdlsAndMoveToDestination
public void addMvnIdToIdlsAndMoveToDestination(Path destPath) throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
compileAvpr
public void compileAvpr(Path pSources) throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
toString
public String toString()
will be overwritten as needed, and override will include this result.
-
getRepoSystem
public final org.eclipse.aether.RepositorySystem getRepoSystem()
-
getMavenSession
public final org.apache.maven.execution.MavenSession getMavenSession()
-
getMavenProject
public final org.apache.maven.project.MavenProject getMavenProject()
-
getGeneratedAvscTarget
public final File getGeneratedAvscTarget()
-
getTarget
public final File getTarget()
-
-