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

com.github.iarellano.j2y2j.Json2YamlConverterMojo Maven / Gradle / Ivy

Go to download

This plugin allows to convert files from json to yaml and vice versa. It makes use of the Apache Maven Filtering component therefore filtering can also be performed.

The newest version!
package com.github.iarellano.j2y2j;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

/**
 * Goal which touches a timestamp file.
 */
@Mojo(name = "json-2-yaml", defaultPhase = LifecyclePhase.PROCESS_SOURCES)
public class Json2YamlConverterMojo
        extends AbstractConverterMojo {

    @Parameter(defaultValue = "yaml", property = "convert.yml.outputExtension")
    private String outputExtension;

    public void execute()
            throws MojoExecutionException {
        super.execute();
    }

    @Override
    protected ObjectMapper getReader() {
        return new ObjectMapper();
    }

    @Override
    protected ObjectMapper getWriter() {
        ObjectMapper writer = new YAMLMapper();
        if (isPrettyPrintJsonEnabled()) {
            writer.enable(SerializationFeature.INDENT_OUTPUT);
        }
        return writer;
    }

    @Override
    protected String getFileExtension() {
        return outputExtension;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy