use of com.developmentontheedge.be5.metadata.exception.ProjectLoadException in project be5 by DevelopmentOnTheEdge.
the class ModuleLoader2 method loadModules.
public static List<Project> loadModules(Project application, ProcessController logger, LoadContext loadContext) throws ProjectLoadException {
List<Project> result = new ArrayList<>();
for (Module module : application.getModules()) {
if (containsModule(module.getName())) {
Project moduleProject = modulesMap.get(module.getName());
result.add(moduleProject);
} else {
throw new RuntimeException("Module project not found " + module.getName());
}
}
// todo ????? topological sort?
result.sort((o1, o2) -> {
if (o1.getModules().contains(o2.getName()))
return 1;
if (o2.getModules().contains(o1.getName()))
return -1;
return 0;
});
return result;
}
use of com.developmentontheedge.be5.metadata.exception.ProjectLoadException in project be5 by DevelopmentOnTheEdge.
the class Be5Mojo method init.
// /////////////////////////////////////////////////////////////////
public void init() throws MojoFailureException {
long startTime = System.nanoTime();
initLogging();
if (be5Project == null) {
if (projectPath == null)
throw new MojoFailureException("Please specify projectPath attribute");
getLog().info("Reading be5 project from '" + projectPath + "'...");
be5Project = loadProject(projectPath.toPath());
if (debug) {
be5Project.setDebugStream(System.err);
}
try {
ModuleLoader2.mergeModules(be5Project, logger);
} catch (ProjectLoadException e) {
e.printStackTrace();
throw new MojoFailureException(e.getMessage());
}
}
if (connectionProfileName != null) {
be5Project.setConnectionProfileName(connectionProfileName);
}
BeConnectionProfile profile = be5Project.getConnectionProfile();
if (profile != null) {
this.be5Project.setDatabaseSystem(Rdbms.getRdbms(profile.getConnectionUrl()));
this.connector = new SimpleConnector(Rdbms.getRdbms(profile.getConnectionUrl()).getType(), profile.getConnectionUrl(), profile.getUsername(), connectionPassword != null ? connectionPassword : profile.getPassword());
getLog().info("Using connection " + DatabaseUtils.formatUrl(profile.getConnectionUrl(), profile.getUsername(), "xxxxx"));
} else {
throw new MojoFailureException("Please specify connection profile: create " + be5Project.getProjectFileStructure().getSelectedProfileFile() + " file with profile name or use -DBE5_PROFILE=...");
}
getLog().info(ModuleLoader2.logLoadedProject(be5Project, startTime));
}
use of com.developmentontheedge.be5.metadata.exception.ProjectLoadException in project be5 by DevelopmentOnTheEdge.
the class Be5Mojo method loadProject.
protected Project loadProject(final Path root) throws MojoFailureException {
final LoadContext loadContext = new LoadContext();
Project prj;
try {
prj = Serialization.load(root, loadContext);
} catch (final ProjectLoadException e) {
throw new MojoFailureException("Can not load project", e);
}
checkErrors(loadContext, "Project has %d error(s)");
return prj;
}
use of com.developmentontheedge.be5.metadata.exception.ProjectLoadException in project be5 by DevelopmentOnTheEdge.
the class Serialization method load.
/**
* @param root
* @param fuseTemplates whether to fuse templates into entities (useful for modules loading)
* @param loadContext
* @return
* @throws ProjectLoadException
* @see Serialization#canBeLoaded(Path)
*/
public static Project load(final Path root, final boolean fuseTemplates, final LoadContext loadContext) throws ProjectLoadException {
Objects.requireNonNull(root);
turnOffAutomaticSerialization();
try {
return new YamlDeserializer(loadContext == null ? new LoadContext() : loadContext, fuseTemplates).readProject(root);
} catch (final ReadException e) {
throw new ProjectLoadException(root, e);
} finally {
turnOnAutomaticSerialization();
}
}
use of com.developmentontheedge.be5.metadata.exception.ProjectLoadException in project be5 by DevelopmentOnTheEdge.
the class ModuleLoader2Test method loadAllProjectsTestWithDev.
@Test
public void loadAllProjectsTestWithDev() throws IOException, ProjectSaveException, ProjectLoadException {
try (PrintWriter out = new PrintWriter(path.resolve("dev.yaml").toFile())) {
out.println("paths:" + "\n test: " + path.toAbsolutePath());
}
ModuleLoader2.loadAllProjects(Collections.singletonList(path.resolve("project.yaml").toUri().toURL()));
ModuleLoader2.readDevPathsToSourceProjects(Collections.singletonList(path.resolve("dev.yaml").toUri().toURL()));
assertTrue(ModuleLoader2.getPathsToProjectsToHotReload().toString().startsWith("{test="));
assertEquals(1, ModuleLoader2.getPathsToProjectsToHotReload().size());
Project loadProject = ModuleLoader2.findAndLoadProjectWithModules();
assertEquals("test", loadProject.getAppName());
ModuleLoader2.getFileSystem(loadProject, "test");
}
Aggregations