@Override public void configure(final Env env, final Config conf, final Binder binder) throws Throwable { Path userdir = Paths.get(System.getProperty("user.dir")); Path workDirectory = Optional.ofNullable(this.workDirectory) .orElse(userdir); Path installDirectory = Optional.ofNullable(this.installDirectory).orElse(workDirectory); ProxyConfig proxy = new ProxyConfig(proxies(conf)); CacheResolver cache = Files.exists(userdir.resolve("pom.xml")) ? new MavenCacheResolver() : null; FrontendPluginFactory factory = new FrontendPluginFactory(workDirectory.toFile(), installDirectory.toFile(), cache); installNode(conf, nodeVersion, proxy, factory); Map<String, String> environment = environment(conf); NodeTask task = newTask(factory, conf, proxy, environment, nodeVersion); onSyncPackageJson(conf, workDirectory, task::executeSync); if (onStart == null && onStarted == null) { onStart = cmd -> cmd.execute("run", "build"); } if (onStart != null) { env.onStart(() -> onStart.accept(task)); } if (onStarted != null) { env.onStarted(() -> onStarted.accept(task)); } }
@Override public void execute() throws MojoFailureException { if (testFailureIgnore && !isTestingPhase()) { getLog().info("testFailureIgnore property is ignored in non test phases"); } if (!(skipTestPhase() || skipExecution())) { if (installDirectory == null) { installDirectory = workingDirectory; } try { execute(new FrontendPluginFactory(workingDirectory, installDirectory, new RepositoryCacheResolver(repositorySystemSession))); } catch (TaskRunnerException e) { if (testFailureIgnore && isTestingPhase()) { getLog().error("There are test failures.\nFailed to run task: " + e.getMessage(), e); } else { throw new MojoFailureException("Failed to run task", e); } } catch (FrontendException e) { throw MojoUtils.toMojoFailureException(e); } } else { getLog().info("Skipping execution."); } }
public NodeManager(Log log, File nodeDirectory, AbstractWisdomMojo mojo) { this.factory = new FrontendPluginFactory(mojo.basedir, nodeDirectory); this.npmInstallationFactory = new FrontendPluginFactory(nodeDirectory, nodeDirectory); this.nodeDirectory = nodeDirectory; this.mojo = mojo; if (!nodeDirectory.exists()) { nodeDirectory.mkdirs(); } }
private GulpRunner downloadNode(File workingDirectory, ProxyConfig proxyConfig, String nodeVersion) { FrontendPluginFactory factory = new FrontendPluginFactory( workingDirectory, workingDirectory); try { factory.getNodeInstaller(proxyConfig).setNodeVersion(nodeVersion) .setNodeDownloadRoot( NodeInstaller.DEFAULT_NODEJS_DOWNLOAD_ROOT) .install(); } catch (InstallationException e) { throw new IllegalStateException("Failed to download node", e); } return factory.getGulpRunner(); }
private YarnRunner downloadYarn(File workingDirectory, ProxyConfig proxyConfig, String npmRegistryUrl, String yarnVersion) { FrontendPluginFactory factory = new FrontendPluginFactory( workingDirectory, workingDirectory); try { factory.getYarnInstaller(proxyConfig).setYarnVersion(yarnVersion) .setYarnDownloadRoot( YarnInstaller.DEFAULT_YARN_DOWNLOAD_ROOT) .install(); } catch (InstallationException e) { throw new IllegalStateException("Failed to download yarn", e); } return factory.getYarnRunner(proxyConfig, validateUrl(npmRegistryUrl)); }
@Override public void execute() throws MojoFailureException { if (testFailureIgnore && !isTestingPhase()) { getLog().info("testFailureIgnore property is ignored in non test phases"); } if (!(skipTestPhase() || skipExecution())) { if (installDirectory == null) { installDirectory = workingDirectory; } try { execute(new FrontendPluginFactory(workingDirectory, installDirectory, new RepositoryCacheResolver(repositorySystemSession))); } catch (TaskRunnerException e) { if (testFailureIgnore && isTestingPhase()) { getLog().error("There are test failures.\nFailed to run task: " + e.getMessage(), e); } else { throw new MojoFailureException("Failed to run task", e); } } catch (FrontendException e) { throw MojoUtils.toMojoFailureException(e); } } else { getLog().info("Skipping execution."); } }