use of ilargia.entitas.codeGeneration.config.CodeGeneratorConfig in project Entitas-Java by Rubentxu.
the class EntitasGradleProject method getCodeGenerator.
@Override
public CodeGenerator getCodeGenerator() {
Properties properties = loadProperties();
CodeGeneratorConfig config = new CodeGeneratorConfig();
config.configure(properties);
List<Class> types = loadTypesFromPlugins(properties);
List<ICodeGeneratorDataProvider> dataProviders = getEnabledInstances(types, config.getDataProviders(), ICodeGeneratorDataProvider.class);
List<ICodeGenerator> codeGenerators = getEnabledInstances(types, config.getCodeGenerators(), ICodeGenerator.class);
List<ICodeGenFilePostProcessor> postProcessors = getEnabledInstances(types, config.getPostProcessors(), ICodeGenFilePostProcessor.class);
configure(dataProviders, properties);
configure(codeGenerators, properties);
configure(postProcessors, properties);
return new CodeGenerator(dataProviders, codeGenerators, postProcessors);
}
use of ilargia.entitas.codeGeneration.config.CodeGeneratorConfig in project Entitas-Java by Rubentxu.
the class FixConfig method run.
@Override
public void run(String[] args) {
System.out.println("Entitas Code Generator version " + 1);
if (assertProperties()) {
try {
//loadProperties();
Properties properties = null;
CodeGeneratorConfig config = new CodeGeneratorConfig();
config.configure(properties);
forceAddKeys(config.getDefaultProperties(), properties);
List<Class> Classs = null;
try {
Classs = CodeGeneratorUtil.loadTypesFromPlugins(properties);
getConfigurables(Classs, config);
} catch (Exception ex) {
throw ex;
}
Set<String> askedRemoveKeys = new HashSet<String>();
Set<String> askedAddKeys = new HashSet<String>();
while (fix(askedRemoveKeys, askedAddKeys, Classs, config, properties)) {
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
use of ilargia.entitas.codeGeneration.config.CodeGeneratorConfig in project Entitas-Java by Rubentxu.
the class NewConfig method run.
@Override
public void run(String[] args) {
Path currentRelativePath = Paths.get("");
String currentDir = currentRelativePath.toAbsolutePath().toString();
File path = new File(currentDir + "/");
if (ArgsExtension.isForce(Arrays.asList(args)) || !path.exists()) {
CodeGeneratorConfig defaultConfig = new CodeGeneratorConfig();
Properties properties = new Properties(defaultConfig.getDefaultProperties());
defaultConfig.configure(properties);
saveProperties(properties, path.getAbsolutePath());
new EditConfig().run(args);
} else {
System.out.println(path + " already exists!");
System.out.println("Use entitas new -f to overwrite the exiting file.");
System.out.println("Use entitas edit to open the exiting file.");
}
}
use of ilargia.entitas.codeGeneration.config.CodeGeneratorConfig in project Entitas-Java by Rubentxu.
the class CodeGeneratorUtil method loadTypesFromPlugins.
public static List<Class> loadTypesFromPlugins(Properties properties) {
CodeGeneratorConfig config = new CodeGeneratorConfig();
config.configure(properties);
return config.getPlugins().stream().flatMap(s -> ClassFinder.findRecursive(s).stream()).sorted((typeA, typeB) -> typeA.getCanonicalName().compareTo(typeB.getCanonicalName())).collect(Collectors.toList());
}
use of ilargia.entitas.codeGeneration.config.CodeGeneratorConfig in project Entitas-Java by Rubentxu.
the class Status method run.
@Override
public void run(String[] args) {
System.out.println("Entitas Code Generator version " + 1);
if (assertProperties()) {
Properties properties = null;
try {
properties = loadProperties();
CodeGeneratorConfig config = new CodeGeneratorConfig();
config.configure(properties);
System.out.println(config.toString());
List<Class> types = null;
Map<String, String> configurables = null;
try {
types = CodeGeneratorUtil.loadTypesFromPlugins(properties);
configurables = CodeGeneratorUtil.getConfigurables(CodeGeneratorUtil.getUsed(types, config.getDataProviders(), ICodeGeneratorDataProvider.class), CodeGeneratorUtil.getUsed(types, config.getCodeGenerators(), ICodeGenerator.class), CodeGeneratorUtil.getUsed(types, config.getPostProcessors(), ICodeGenFilePostProcessor.class));
} catch (Exception ex) {
printKeyStatus(config.getDefaultProperties().keySet(), properties);
throw ex;
}
config.getDefaultProperties().putAll(configurables);
Set<Object> requiredKeys = config.getDefaultProperties().keySet();
printKeyStatus(requiredKeys, properties);
printPluginStatus(types, config);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Aggregations