Codegen

Generate code

Лицензия

Лицензия

Категории

Категории

CLI Взаимодействие с пользователем
Группа

Группа

io.github.h4j4x.codegen
Идентификатор

Идентификатор

cli
Последняя версия

Последняя версия

0.0.6
Дата

Дата

Тип

Тип

pom.sha512
Описание

Описание

Codegen
Generate code
Ссылка на сайт

Ссылка на сайт

https://github.com/h4j4x/codegen
Система контроля версий

Система контроля версий

https://github.com/h4j4x/codegen

Скачать cli

Имя Файла Размер
cli-0.0.6.pom
cli-0.0.6-sources.jar 1 KB
cli-0.0.6-javadoc.jar 105 KB
Обзор

Зависимости

runtime (2)

Идентификатор библиотеки Тип Версия
io.github.h4j4x.codegen : lib jar 0.0.6
args4j : args4j jar 2.33

Модули Проекта

Данный проект не имеет модулей.

CodeGen

Gradle build Pre release Maven Central javadoc Codacy Badge

Generate code from Freemarker templates and JSON data with CSV support.

How to use it?

From terminal:

Download cli latest version and unzip it. From the root folder of application, you should see a folder structure similar to the following:

├── bin
│   └── cli
│   └── cli.bat
├── lib
│   └── ...

Execute according your operating system.

$ bin/cli \
    --verbose \
    --overwrite \
    --read-recursive \
    -d DATA_FOLDER \
    -t TEMPLATES_FOLDER \
    -o OUTPUT_FOLDER

From gradle script:

Create configuration:

configurations {
    codegen
}

Declare dependencies:

dependencies {
    codegen (
        "io.github.h4j4x.codegen:cli:${latestVersion}",
        "io.github.h4j4x.codegen:lib:${latestVersion}",
    )
}

Create gradle task:

task codegen {
    description = 'Generate code'
    javaexec {
        classpath = configurations.codegen
        main = 'io.github.h4j4x.codegen.cli.CliApp'
        args = [
            '-d', "$projectDir/src/main/resources/data",
            '-t', "$projectDir/src/main/resources/template",
            '-o', "$projectDir/src/main/java",
        ]
    }
}

Configuration

--verbose

Verbose mode (info, warning and error logs).

--overwrite

Overwrite mode (output files will replace existing ones).

--read-recursive

Data folder and sub-folders will be read for JSON files.

-d

Data folder for generation.

How to structure data?

Data must be specified in JSON files (.json) with following structure:

  • With CSV (test.csv inside data folder).
{
  "templates": [{
    "template": "test.ftl",
    "file": "folder/TestClass.java"
  }],
  "csvData": {
    "csvKey": "items",
    "dataKey": "data",
    "fields": ["key", "description"],
    "filePath": "test.csv",
    "data": {
      "generalConfig": "Some config"
    }
  }
}
  • Without CSV.
{
  "templates": [{
    "template": "test.ftl",
    "file": "folder/TestClass.java"
  }],
  "data": {
    "key": "value"
  }
}

-t

Templates folder for generation. Templates must be specified in FTL files (.ftl).

-o

Output folder for generation. Must be writable.

License

License

Версии библиотеки

Версия
0.0.6
0.0.5