Repository navigation
Home
genj - Generate a Java project from a template
genj -t TEMPLATE -d DESTINATION [OPTIONS]
genj is a command-line tool written in Rust that generates a Java project from a template (ZIP file or folder).
The binary reads a template, copies files to the destination directory while applying variable replacements
in file paths and content. It also handles the transformation of the ${PACKAGE} variable into a Java folder hierarchy.
Path to the template (ZIP file or folder).
Destination directory where the project will be created.
Project name (default: Demo).
Author name (default: Unknown Author).
Author email (default: email@unknown.local).
Project version (default: 0.0.1).
JDK version to target (e.g., 25). Also used in pom.xml and build.gradle (default: 25).
JDK flavor for sdkman (e.g., 25-zulu) (default: 25-zulu).
Java package name (default: com.demo).
Main class name (default: App).
Build tool to use: maven or gradle (default: maven).
Maven version for .sdkmanrc (default: 3.9.5).
Gradle version for .sdkmanrc (default: 8.5).
Vendor name (usable in templates) (default: Vendor).
The following patterns are replaced in files and file names:
| Variable | Description |
|---|---|
${PROJECT_NAME} |
Project name |
${AUTHOR_NAME} |
Author name |
${AUTHOR_EMAIL} |
Author email |
${PROJECT_VERSION} |
Project version |
${PACKAGE} |
Java package (transformed into folder hierarchy, e.g., com.example becomes com/example) |
${MAINCLASS} |
Main class name |
${PROJECT_YEAR} |
Current year |
${JAVA} |
JDK version |
${VENDOR_NAME} |
Vendor name |
genj automatically generates the following files:
Maven build configuration (if --build maven).
Gradle build configuration (if --build gradle).
SDKMan configuration file with Java and build tool versions.
VSCode Java project settings.
VSCode launch configuration for debugging.
Git repository initialized with initial commit.
genj -t templates/basic-java -d ./out -n Demo \
-a "Frédéric Delorme" -e fred@example.com \
-v 0.1.0 -k com.demo -m Appgenj -t template.zip -d ./out -n MyProject \
-b gradle --gradle_version 8.5genj -t templates/basic-java -d ./out -n Demo \
-j 25 -f 25-zulugenj \
--template templates/basic-java \
--destination ./projects \
--project_name MyApp \
--author "John Doe" \
--email john@example.com \
--project_version 1.0.0 \
--java_version 21 \
--java_flavor 21-zulu \
--package com.company.app \
--mainclass MyApp \
--build gradle \
--gradle_version 8.7 \
--vendor_name "My Company"- The program creates the destination directory as
<destination>/<project_name>. - If the template is a ZIP file, the script attempts to remove a common root prefix present in the archive.
- Binary files detected (non-text) are copied as is; only text files undergo variable replacements.
- The Git repository is automatically initialized with an initial commit.
Frédéric Delorme
1.2.0
For more information, visit the project repository or consult the README.md file.