Giter VIP home page Giter VIP logo

template-generator-maven-plugin's Introduction

Template-generator-maven-plugin

The Apache License Maven Central Build Status

A Maven plugin that generates code using template engines.

References

Contributing

Git flow with following settings:

  • Branch name for production releases: master
  • Branch name for "next release" development: develop
  • Feature branches? feature/
  • Bugfix branches? bugfix/
  • Release branches? release/
  • Hotfix branches? hotfix/
  • Support branches? support/
  • Version tag prefix? []

Use

Stable versions

<plugin>
    <groupId>com.danidemi</groupId>
    <artifactId>template-generator-maven-plugin</artifactId>
    <version>0.0.5</version>
</plugin>

Snapshot versions

Available here: https://oss.sonatype.org/content/repositories/snapshots/com/danidemi/template-generator-maven-plugin/, to use in a project, please enable this

<repositories>
    <repository>
        <id>central</id>
        <name>Sonatype Snapshot</name>
        <layout>default</layout>
        <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

Dev Notes

mvn com.danidemi:template-generator-maven-plugin:0.0.1-SNAPSHOT:generate
mvn install com.danidemi:template-generator-maven-plugin:0.0.1-SNAPSHOT:generate -e -X -Dgenerate.pathToCsv=Hollow
mvn install com.danidemi:template-generator-maven-plugin:0.0.1-SNAPSHOT:generate -e -X -Dgenerate.pathToCsv=${project.build.testSourceDirectory}
mvn install com.danidemi:template-generator-maven-plugin:0.0.1-SNAPSHOT:generate -e -X -Dgenerate.pathToCsv=C:\Users\danidemi\workspace\repos\danidemi\template-generator-maven-plugin\src\test\resources\codeAndCountry.csv
mvn install com.danidemi:template-generator-maven-plugin:0.0.1-SNAPSHOT:generate -e -X -Dgenerate.pathToCsv=${project.build.testSourceDirectory}\..\resources\codeAndCountry.csv
mvn install com.danidemi:template-generator-maven-plugin:0.0.1-SNAPSHOT:generate -e -X -Dgenerate.pathToCsv=${project.build.testSourceDirectory}\..\resources\codeAndCountry.csv -Dgenerate.pathToTemplate=${project.build.sourceDirectory}\..\resources\Money.java.vm -Dgenerate.pathToOutputFolder=${project.build.directory}\generated

Release

Stable versions

mvn versions:set
mvn clean install
mvn clean deploy -P release
mvn versions:set

Snapshot versions

mvn clean deploy

template-generator-maven-plugin's People

Contributors

danidemi avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

chandanws

template-generator-maven-plugin's Issues

Plug-in user wants to copy paste configuration examples from the online doc to her pom.

  • In order to
    • understand how the plug-in works
    • properly use the plug-in in my project
  • As a
    • plug-in user that is totally new to the plug-in
  • I want
    • some generic enough examples in the doc that I can copy paste in my pom that will reasonably work out of the box.

Examples to be included

  • Generation of .java classes and their inclusion with the helper-plugin.
  • Generation of resources file and their inclusion with the helper-plugin.
  • Generation of files with "one-context-per-row" strategy.
  • Generation of files with "one-context-per-file" strategy.
  • Generation of files with "one-context-per-tag" strategy.
  • An example about using meta data.

To write an effective template I want the metadata of a row to contain the "isLast" attribute.

In order to write a more effective template
as a plug-in user
I want the metadata of a row to contain the "isLast" attribute.

Rationale

Instead of writing...

${row.data.Country.replace(' ','_')}("${row.data.Code}", "${row.data.Continent}")#if( ${row.meta.count} == ${source.rows.size()} );#else,#end

would not it be better to write something as...

${row.data.Country.replace(' ','_')}("${row.data.Code}", "${row.data.Continent}")#if( ${row.meta.last} );#else,#end

...?

Plug-in user wants the data model exposed to the template to be always the same

  • In order to
    • easily understand what info I can reference in the template file
    • switch easily from one context mode to another
  • As a
    • plug-in user that should manage differen templates
  • I want
    • the data model exposed to a template to be always the same
    • regardless of the context mode.

Ideas

The structure of the model could well be this one:

{
    "rows": [
        {
            "data": {
                "field-1": "value-of-header-1-in-row-1",
                "field-2": "value-of-header-2-in-row-1",
                "field-n": "value-of-header-n-in-row-1"
            },
            "meta": {
                "rowIndex": "0",
                "rowCount": "1",
                "sourceIndex": "0-based-index-of-row-1-in-the-source-file",
                "sourceCount": "1-based-index-of-row-1-in-the-source-file"
            }
        },
        {
            "data": {
                "field-1": "value-of-header-1-in-row-2",
                "field-2": "value-of-header-2-in-row-2",
                "field-n": "value-of-header-n-in-row-2"
            },
            "meta": {
                "rowIndex": "1",
                "rowCount": "2",
                "sourceIndex": "0-based-index-of-row-2-in-the-source-file",
                "sourceCount": "1-based-index-of-row-2-in-the-source-file"
            }
        },
        {
            "data": {
                "field-1": "value-of-header-1-in-row-m",
                "field-2": "value-of-header-2-in-row-m",
                "field-n": "value-of-header-n-in-row-m"
            },
            "meta": {
                "rowIndex": "m-1",
                "rowCount": "m",
                "sourceIndex": "0-based-index-of-row-m-in-the-source-file",
                "sourceCount": "1-based-index-of-row-m-in-the-source-file"
            }
        }  
    ],
    "meta": {
        "template" : {
            "path" : "<path-to-the-template-file>",
            "name" : "<name-of-template-file>"
        },
        "source" : {
            "path": "<path-to-the-csv-file>",
            "name": "<name-of-csv-file>"
        },
        "target" : {
            "path": "<path-to-the-generated-file>",
            "name": "<name-of-generated-file>"            
        },
        "count" : {
            "rows": "<total-number-of-rows>",
            "lastIndex": "<0-based-index-of-last-row>"
        },
        "tags": [ "<tag-1>", "<tag-2>", "<tag-n>"]
    }
}

PlugIn user wants a more descriptive error when an unknown mode is specified

In order to use the plugin in a more effective way
as a plugin user
I want the error message in case I use an unknown mode to be more descriptive.

Rationale

I got this error running the plgin...

$ mvn clean generate-sources
Cannot convert 'ONE_CONTEXT_PER_ROW' to Enum: No enum constant com.danidemi.templategeneratormavenplugin.maven.GenerateMojo.ContextMode.ONE_CONTEXT_PER_ROW

...now, am I allowed to know which are the enum constants without being forced to check the doc or the source ?

Plug in user wants to be warned when a row is going to overwrite a target file produced by a previous row.

To avoid messing up with large csv file and complex template
as a busy developer
I'd like the plugin to warn me if a row from the CSV is going to generate a target file that was previously generated from another row.

Rationale

Let's suppose I've wronlgy set up the generation mode to ONE_CONTEXT_PER_LINE and I set a FileNameTemplate that makes to different rows to match the same file. Wouldn't it be better in this case to stop the generation saying that we are going to generate a file that was already generated ?

Plug-in user don't want target files to be generated when there is no need to recreate them.

  • In order to
    • speed up the generation of sources
  • As a
    • plug-in user that has to run multiple times mvn generate-sources
  • I want
    • that plug-in does not recreate target files if both template and csv didn't change since last generation.

Ideas

  • The template file has a "last modified date".
  • The CSV file has a "last modified date".
  • The generated file has a "creation date". If that creation date is later than both template and CSV it means it is up to date.
  • When the template or the CSV files have a bigger date it means they have been modfied after the generation, so the generated file should be probably regenerated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.