@Override protected NodeTask newTask(FrontendPluginFactory factory, Config conf, ProxyConfig proxy, Map<String, String> env, String nodeVersion) throws InstallationException { Function<String, String> property = key -> conf.hasPath(key) ? conf.getString(key) : null; factory.getYarnInstaller(proxy) .setYarnVersion(yarnVersion) .setYarnDownloadRoot(conf.getString("yarn.downloadRoot")) .setUserName(property.apply("yarn.username")) .setPassword(property.apply("yarn.password")) .install(); YarnRunner yarn = factory.getYarnRunner(proxy, conf.getString("npm.registryURL")); return (cmd, args) -> { String cmdline = cmd + " " + Arrays.asList(args).stream().collect(Collectors.joining(" ")); yarn.execute(cmdline, env); }; }
@Override public void execute(FrontendPluginFactory factory) throws InstallationException { ProxyConfig proxyConfig = MojoUtils.getProxyConfig(this.session, this.decrypter); Server server = MojoUtils.decryptServer(this.serverId, this.session, this.decrypter); if (null != server) { factory.getNodeInstaller(proxyConfig).setNodeDownloadRoot(this.nodeDownloadRoot) .setNodeVersion(this.nodeVersion).setPassword(server.getPassword()) .setUserName(server.getUsername()).install(); factory.getYarnInstaller(proxyConfig).setYarnDownloadRoot(this.yarnDownloadRoot) .setYarnVersion(this.yarnVersion).setUserName(server.getUsername()) .setPassword(server.getPassword()).install(); } else { factory.getNodeInstaller(proxyConfig).setNodeDownloadRoot(this.nodeDownloadRoot) .setNodeVersion(this.nodeVersion).install(); factory.getYarnInstaller(proxyConfig).setYarnDownloadRoot(this.yarnDownloadRoot) .setYarnVersion(this.yarnVersion).install(); } }
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(FrontendPluginFactory factory) throws InstallationException { ProxyConfig proxyConfig = MojoUtils.getProxyConfig(this.session, this.decrypter); Server server = MojoUtils.decryptServer(this.serverId, this.session, this.decrypter); if (null != server) { factory.getNodeInstaller(proxyConfig).setNodeDownloadRoot(this.nodeDownloadRoot) .setNodeVersion(this.nodeVersion).setPassword(server.getPassword()) .setUserName(server.getUsername()).install(); factory.getYarnInstaller(proxyConfig).setYarnDownloadRoot(this.yarnDownloadRoot) .setYarnVersion(this.yarnVersion).setUserName(server.getUsername()) .setPassword(server.getPassword()).install(); } else { factory.getNodeInstaller(proxyConfig).setNodeDownloadRoot(this.nodeDownloadRoot) .setNodeVersion(this.nodeVersion).install(); factory.getYarnInstaller(proxyConfig).setYarnDownloadRoot(this.yarnDownloadRoot) .setYarnVersion(this.yarnVersion).install(); } }