use of com.vaadin.flow.server.ExecutionFailedException in project flow by vaadin.
the class BuildFrontendMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
long start = System.nanoTime();
try {
BuildFrontendUtil.runNodeUpdater(this);
} catch (ExecutionFailedException | URISyntaxException exception) {
throw new MojoFailureException("Could not execute build-frontend goal", exception);
}
if (generateBundle()) {
try {
BuildFrontendUtil.runFrontendBuild(this);
} catch (URISyntaxException | TimeoutException exception) {
throw new MojoExecutionException(exception.getMessage(), exception);
}
}
BuildFrontendUtil.updateBuildFile(this);
long ms = (System.nanoTime() - start) / 1000000;
getLog().info("Build frontend completed in " + ms + " ms.");
}
use of com.vaadin.flow.server.ExecutionFailedException in project flow by vaadin.
the class BuildFrontendUtil method runNodeUpdater.
/**
* runs the node-Updater.
*
* @param adapter
* - the PluginAdapterBase.
* @throws ExecutionFailedException
* - a ExecutionFailedException.
* @throws URISyntaxException
* - - Could not build an URI from nodeDownloadRoot().
*/
public static void runNodeUpdater(PluginAdapterBuild adapter) throws ExecutionFailedException, URISyntaxException {
Set<File> jarFiles = adapter.getJarFiles();
File flowResourcesFolder = new File(adapter.npmFolder(), Paths.get(adapter.buildFolder(), DEFAULT_FLOW_RESOURCES_FOLDER).toString());
final URI nodeDownloadRootURI;
nodeDownloadRootURI = adapter.nodeDownloadRoot();
ClassFinder classFinder = adapter.getClassFinder();
Lookup lookup = adapter.createLookup(classFinder);
try {
new NodeTasks.Builder(lookup, adapter.npmFolder(), adapter.generatedFolder(), adapter.frontendDirectory(), adapter.buildFolder()).runNpmInstall(adapter.runNpmInstall()).withWebpack(adapter.webpackOutputDirectory(), adapter.servletResourceOutputDirectory()).useV14Bootstrap(adapter.isUseDeprecatedV14Bootstrapping()).enablePackagesUpdate(true).useByteCodeScanner(adapter.optimizeBundle()).withFlowResourcesFolder(flowResourcesFolder).copyResources(jarFiles).copyTemplates(true).copyLocalResources(adapter.frontendResourcesDirectory()).enableImportsUpdate(true).withEmbeddableWebComponents(adapter.generateEmbeddableWebComponents()).withTokenFile(BuildFrontendUtil.getTokenFile(adapter)).enablePnpm(adapter.pnpmEnable()).useGlobalPnpm(adapter.useGlobalPnpm()).withApplicationProperties(adapter.applicationProperties()).withEndpointSourceFolder(adapter.javaSourceFolder()).withEndpointGeneratedOpenAPIFile(adapter.openApiJsonFile()).withFrontendGeneratedFolder(adapter.generatedTsFolder()).withHomeNodeExecRequired(adapter.requireHomeNodeExec()).withNodeVersion(adapter.nodeVersion()).withNodeDownloadRoot(nodeDownloadRootURI).setNodeAutoUpdate(adapter.nodeAutoUpdate()).setJavaResourceFolder(adapter.javaResourceFolder()).withPostinstallPackages(adapter.postinstallPackages()).build().execute();
} catch (ExecutionFailedException exception) {
throw exception;
} catch (Throwable throwable) {
// NOSONAR Intentionally throwable
throw new ExecutionFailedException("Error occured during goal execution: " + throwable.getMessage() + "Please run Maven with the -e switch (or Gradle with the --stacktrace switch), to learn the full stack trace.", throwable);
}
}
use of com.vaadin.flow.server.ExecutionFailedException in project flow by vaadin.
the class DevModeInitializer method runNodeTasks.
private static void runNodeTasks(VaadinContext vaadinContext, JsonObject tokenFileData, NodeTasks tasks) {
try {
tasks.execute();
FallbackChunk chunk = FrontendUtils.readFallbackChunk(tokenFileData);
if (chunk != null) {
vaadinContext.setAttribute(chunk);
}
} catch (ExecutionFailedException exception) {
log().debug("Could not initialize dev mode handler. One of the node tasks failed", exception);
throw new CompletionException(exception);
}
}
use of com.vaadin.flow.server.ExecutionFailedException in project flow by vaadin.
the class TaskUpdateThemeImportTest method taskExecuted_customThemeFolderExistsInBothStaticResourcesAndInClasspath_throwsException.
@Test
public void taskExecuted_customThemeFolderExistsInBothStaticResourcesAndInClasspath_throwsException() {
String staticResources = String.join("/", APPLICATION_STATIC_RESOURCES, CUSTOM_THEME_PATH);
File themeDir = new File(projectRoot, staticResources);
Assert.assertTrue(themeDir.mkdirs());
String classPathThemePath = NODE_MODULES + FLOW_NPM_PACKAGE_NAME + CUSTOM_THEME_PATH;
File classPathThemeDir = new File(projectRoot, classPathThemePath);
Assert.assertTrue(classPathThemeDir.mkdirs());
ExecutionFailedException e = Assert.assertThrows(ExecutionFailedException.class, taskUpdateThemeImport::execute);
Assert.assertTrue(e.getMessage(), e.getMessage().contains(String.format("Theme '%s' should not exist inside a " + "jar and in the project at the same time.", CUSTOM_THEME_NAME)));
}
use of com.vaadin.flow.server.ExecutionFailedException in project flow by vaadin.
the class TaskUpdateThemeImportTest method taskExecuted_customThemeFolderExistsInFrontendAndStaticAndMetaInfResources_throwsException.
@Test
public void taskExecuted_customThemeFolderExistsInFrontendAndStaticAndMetaInfResources_throwsException() {
File themeDir = new File(frontendDirectory, CUSTOM_THEME_PATH);
Assert.assertTrue(themeDir.mkdirs());
String staticResources = String.join("/", APPLICATION_STATIC_RESOURCES, CUSTOM_THEME_PATH);
File themeDirInStatic = new File(projectRoot, staticResources);
Assert.assertTrue(themeDirInStatic.mkdirs());
String metaInfResources = String.join("/", APPLICATION_META_INF_RESOURCES, CUSTOM_THEME_PATH);
File themeDirInMetaInf = new File(projectRoot, metaInfResources);
Assert.assertTrue(themeDirInMetaInf.mkdirs());
ExecutionFailedException e = Assert.assertThrows(ExecutionFailedException.class, taskUpdateThemeImport::execute);
Assert.assertTrue(e.getMessage().contains(String.format("Discovered Theme folder for theme '%s' " + "in more than one place in the project. Please " + "make sure there is only one theme folder with name '%s' " + "exists in the your project. ", CUSTOM_THEME_NAME, CUSTOM_THEME_NAME)));
}
Aggregations