All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.frtu.schema.DotGraphGen4AvroMojo Maven / Gradle / Ivy

Go to download

A maven plugin for schemas (schema2dot - generate a dot notation for Avro schema | pojo2avro - generation from POJO).

There is a newer version: 1.1.0
Show newest version
package com.github.frtu.schema;

import com.github.frtu.schema.utils.AvroDotGenerator;
import com.github.frtu.schema.utils.FileUtil;
import org.apache.avro.Schema;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

/**
 * Generate a Dot graph from Avro schema.
 *
 * @author frtu
 * @since 0.3.6
 */
@Mojo(name = "avro2dot", // configurator = "include-project-dependencies",
        requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
public class DotGraphGen4AvroMojo extends AbstractAvroFiles2xxxMojo {
    private static final Logger LOGGER = LoggerFactory.getLogger(DotGraphGen4AvroMojo.class);

    @Override
    protected void generateFile(String fileBaseName, Schema schema) throws IOException {
        final AvroDotGenerator avroDotGenerator = new AvroDotGenerator(fileBaseName);
        final String fileContent = avroDotGenerator.generateGraph(schema);

        final String filename = fileBaseName + ".dot";
        LOGGER.debug("Generated dot content and writing to {}", filename);
        FileUtil.writeIntoFile(fileContent, filename, this.outputDirectory);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy