com.smartnews.jpa_entity_generator.gradle.EntityGenTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jpa-entity-generator Show documentation
Show all versions of jpa-entity-generator Show documentation
Lombok-wired JPA entity source code generator, Gradle and Maven supported.
package com.smartnews.jpa_entity_generator.gradle;
import com.smartnews.jpa_entity_generator.CodeGenerator;
import com.smartnews.jpa_entity_generator.config.CodeGeneratorConfig;
import freemarker.template.TemplateException;
import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.TaskAction;
import java.io.IOException;
import java.sql.SQLException;
/**
* entityGen Gradle task.
*/
public class EntityGenTask extends DefaultTask {
@TaskAction
public void generateAll() throws IOException, SQLException, TemplateException {
EntityGenExtension ext = getProject().getExtensions().getByType(EntityGenExtension.class);
if (ext == null) {
ext = new EntityGenExtension();
}
CodeGeneratorConfig config = CodeGeneratorConfig.load(ext.getConfigPath());
if (config.isJpa1SupportRequired()) {
if (config.getPackageName().equals(config.getPackageNameForJpa1())) {
throw new IllegalStateException("packageName and packageNameForJpa1 must be different.");
}
CodeGenerator.generateAll(config, true);
}
CodeGenerator.generateAll(config, false);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy