@Override public String toString() { return toCoordinates(); }
@Override public String toString() { return addon.getId().toCoordinates(); }
private Set<String> getEnabledAddons() { Set<String> addons = new HashSet<>(); try { for (AddonRepository repository : furnace.getRepositories()) { System.out.println(repository.getRootDirectory().getCanonicalPath() + ":"); List<AddonId> enabledAddons = repository.listEnabled(); for (AddonId addon : enabledAddons) { addons.add(addon.toCoordinates()); } } } catch (Exception e) { e.printStackTrace(); System.out.println("> Forge version [" + AddonRepositoryImpl.getRuntimeAPIVersion() + "]"); } return addons; }
private Set<String> getEnabledAddons() { Set<String> addons = new HashSet<>(); try { for (AddonRepository repository : furnace.getRepositories()) { System.out.println(repository.getRootDirectory().getCanonicalPath() + ":"); List<AddonId> enabledAddons = repository.listEnabled(); for (AddonId addon : enabledAddons) { addons.add(addon.toCoordinates()); } } } catch (Exception e) { e.printStackTrace(); System.out.println("> Forge version [" + AddonRepositoryImpl.getRuntimeAPIVersion() + "]"); } return addons; }
private void list() { try { for (AddonRepository repository : furnace.getRepositories()) { System.out.println(repository.getRootDirectory().getCanonicalPath() + ":"); List<AddonId> addons = repository.listAll(); for (AddonId addon : addons) { System.out.println(addon.toCoordinates()); } } } catch (Exception e) { e.printStackTrace(); System.out.println("> Forge version [" + AddonRepositoryImpl.getRuntimeAPIVersion() + "]"); } finally { exitAfter = true; } }
private void list() { try { for (AddonRepository repository : furnace.getRepositories()) { System.out.println(repository.getRootDirectory().getCanonicalPath() + ":"); List<AddonId> addons = repository.listAll(); for (AddonId addon : addons) { System.out.println(addon.toCoordinates()); } } } catch (Exception e) { e.printStackTrace(); System.out.println("> Forge version [" + AddonRepositoryImpl.getRuntimeAPIVersion() + "]"); } finally { exitAfter = true; } }
@Override public Result execute(UIExecutionContext context) throws Exception { AddonManager manager = SimpleContainer.getServices(getClass().getClassLoader(), AddonManager.class).get(); Iterable<AddonId> value = addons.getValue(); Iterator<AddonId> iterator = value.iterator(); StringBuilder builder = new StringBuilder(); while (iterator.hasNext()) { AddonId addonId = iterator.next(); builder.append(addonId.toCoordinates()); manager.disable(addonId).perform(); manager.remove(addonId).perform(); if (iterator.hasNext()) builder.append(", "); } return Results.success("Removed addons: " + builder.toString()); } }
@Override public Iterable<String> getCompletionProposals(UIContext context, InputComponent<?, String> input, String value) { Set<String> items = new TreeSet<String>(); Set<Addon> addons = furnace.getAddonRegistry().getAddons(); for (Addon addon : addons) { if (addon.getId().toCoordinates().startsWith(value)) items.add(addon.getId().getName()); } return items; } });
@Override public Result execute(UIExecutionContext context) throws Exception { Furnace furnace = SimpleContainer.getFurnace(getClass().getClassLoader()); Set<AddonId> choices = new TreeSet<>(); for (AddonRepository repository : furnace.getRepositories()) { choices.addAll(repository.listEnabled()); } UIOutput output = context.getUIContext().getProvider().getOutput(); PrintStream out = output.out(); out.println("Currently installed addons:"); for (AddonId addonId : choices) { out.println(addonId.toCoordinates()); } return Results.success(); }
private Collection<DeploymentDescription> generateDependencyDeployments(Method deploymentMethod) { Dependencies dependency = deploymentMethod.getAnnotation(Dependencies.class); Collection<DeploymentDescription> deployments = new ArrayList<DeploymentDescription>(); if (dependency.value() != null) for (Addon addon : dependency.value()) { AddonId id = AddonId.from(addon.name(), addon.version()); DeploymentDescription deploymentDescription = new DeploymentDescription(id.toCoordinates(), ShrinkWrap.create(ForgeRemoteAddon.class).setAddonId(id)); deploymentDescription.shouldBeTestable(false); deployments.add(deploymentDescription); } return deployments; }
@Override public Result execute(UIExecutionContext context) { Furnace furnace = SimpleContainer.getFurnace(getClass().getClassLoader()); AddonManager addonManager = SimpleContainer.getServices(getClass().getClassLoader(), AddonManager.class).get(); AddonDependencyResolver resolver = SimpleContainer .getServices(getClass().getClassLoader(), AddonDependencyResolver.class).get(); Version version = furnace.getVersion(); AddonId addonId = CoordinateUtils.resolveCoordinate(coordinate.getValue(), version, resolver); try { addonManager.install(addonId).perform(); // Invalidate project cache getProjectFactory().invalidateCaches(); return Results.success("Addon " + addonId.toCoordinates() + " was installed successfully."); } catch (Throwable t) { return Results.fail( "Addon " + addonId.toCoordinates() + " could not be installed: " + t.getCause().getMessage(), t); } }
return Results.fail("Addon " + maxAddonId.toCoordinates() + " is already installed with the most updated version."); if (installRequest.getActions().isEmpty()) return Results.fail("Addon " + maxAddonId.toCoordinates() + " is already installed with the most updated version."); return Results.success("Addon " + maxAddonId.toCoordinates() + " was installed successfully."); return Results.fail("Addon " + maxAddonId.toCoordinates() + " could not be installed.", t);
@Override public void initializeUI(UIBuilder builder) throws Exception { InputComponentFactory factory = builder.getInputComponentFactory(); coordinate = factory.createInput("coordinate", String.class).setLabel("Coordinate") .setDescription("The addon's \"groupId:artifactId,version\" coordinate") .setNote("The addon's \"groupId:artifactId,version\" coordinate").setRequired(true); ProjectFactory projectFactory = SimpleContainer.getServices(getClass().getClassLoader(), ProjectFactory.class) .get(); Project project = Projects.getSelectedProject(projectFactory, builder.getUIContext()); if (project != null) { MetadataFacet facet = project.getFacet(MetadataFacet.class); Coordinate c = facet.getOutputDependency().getCoordinate(); coordinate.setDefaultValue(AddonId.from(c.getGroupId() + ":" + c.getArtifactId(), c.getVersion()) .toCoordinates()); } List<String> defaultCoords = Arrays.asList(CoordinateUtils.FORGE_ADDON_GROUP_ID); coordinate.setCompleter((UIContext context, InputComponent<?, String> input, String value) -> { Iterable<String> items = Collections.emptySet(); if (Strings.isNullOrEmpty(value)) { items = defaultCoords; } return items; }); builder.add(coordinate); }