private String toMavenCoords(AddonId addonId) { String coords = addonId.getName() + ":jar:" + this.classifier + ":" + addonId.getVersion(); return coords; }
/** * The name and version, comma separated. */ public String toCoordinates() { StringBuilder coord = new StringBuilder(getName()).append(",").append(getVersion()); return coord.toString(); }
static File getInstallationPathFor(AddonId addonId) { String name = addonId.getName(); // TODO: Read from settings.xml? StringBuilder sb = new StringBuilder(OperatingSystemUtils.getUserHomePath()).append("/.m2/repository/"); sb.append(name.replace('.', '/').replace(':', '/')); sb.append("/").append(addonId.getVersion()); sb.append("/").append(name.substring(name.lastIndexOf(":") + 1)).append("-").append(addonId.getVersion()) .append(".jar"); return new File(sb.toString()); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof AddonId)) return false; AddonId other = (AddonId) obj; if (name == null) { if (other.getName() != null) return false; } else if (!name.equals(other.getName())) return false; if (version == null) { if (other.getVersion() != null) return false; } else if (!version.equals(other.getVersion())) return false; return true; }
@Override public Set<AddonDependencyEntry> getDependencyEntries() { Set<AddonDependencyEntry> entries = new HashSet<AddonDependencyEntry>(); for (Entry<AddonId, Boolean> entry : requiredAddons.entrySet()) { AddonId key = entry.getKey(); Boolean exported = entry.getValue(); entries.add(AddonDependencyEntry.create(key.getName(), key.getVersion().toString(), exported, false)); } for (Entry<AddonId, Boolean> entry : optionalAddons.entrySet()) { AddonId key = entry.getKey(); Boolean exported = entry.getValue(); entries.add(AddonDependencyEntry.create(key.getName(), key.getVersion().toString(), exported, true)); } return entries; }
public AddonInfoBuilder setAPIVersion(Version apiVersion) { AddonId newId = AddonId.from(addon.getName(), addon.getVersion(), apiVersion); this.addon = newId; return this; }
@Override public String toString() { AddonId oldAddon = removeRequest.getRequestedAddonInfo().getAddon(); AddonId newAddon = deployRequest.getRequestedAddonInfo().getAddon(); if (oldAddon.getVersion().equals(newAddon.getVersion())) { return "Update: [" + newAddon + "]"; } else { return "Update: from [" + oldAddon + "] to [" + newAddon + "]"; } } }
@Override public int compareTo(AddonId other) { if (other == null) throw new IllegalArgumentException("Cannot compare against null."); int result = getName().compareTo(other.getName()); if (result == 0) result = getVersion().compareTo(other.getVersion()); if (result == 0) result = getApiVersion().compareTo(other.getApiVersion()); return result; }
@Override public Dependency toDependency(AddonId addon) { String[] mavenCoords = addon.getName().split(":"); Dependency dependency = DependencyBuilder.create().setGroupId(mavenCoords[0]) .setArtifactId(mavenCoords[1]) .setVersion(addon.getVersion().toString()).setClassifier(FORGE_ADDON_CLASSIFIER); return dependency; }
private void addAddonDependency(Project project, StringBuilder dependenciesAnnotationBody, AddonId addonId) { DependencyInstaller dependencyInstaller = SimpleContainer .getServices(getClass().getClassLoader(), DependencyInstaller.class).get(); Dependency dependency = DependencyBuilder.create(addonId.getName()).setVersion( addonId.getVersion().toString()).setClassifier(MavenAddonDependencyResolver.FORGE_ADDON_CLASSIFIER) .setScopeType("test"); String name = addonId.getName(); if (!dependencyInstaller.isInstalled(project, dependency)) { dependencyInstaller.install(project, dependency); } dependenciesAnnotationBody.append("@AddonDependency(name = \"").append(name).append("\")"); }
if (Versions.isSnapshot(addon.getVersion()) && addonInfo.equals(requestedAddonInfo)) Version differentVersion = SingleVersion.valueOf(differentVersionEntry.getKey().getVersion().toString()); Version addonVersion = SingleVersion.valueOf(addon.getVersion().toString());
if (Versions.isSnapshot(addonId.getVersion()))
@Override public Result execute(UIExecutionContext context) throws Exception { Furnace furnace = SimpleContainer.getFurnace(getClass().getClassLoader()); FacetFactory facetFactory = SimpleContainer.getServices(getClass().getClassLoader(), FacetFactory.class).get(); DependencyInstaller dependencyInstaller = SimpleContainer .getServices(getClass().getClassLoader(), DependencyInstaller.class).get(); UIContext uiContext = context.getUIContext(); Project project = getSelectedProject(uiContext); facetFactory.install(project, FurnaceVersionFacet.class); project.getFacet(FurnaceVersionFacet.class).setVersion(furnace.getVersion().toString()); facetFactory.install(project, AddonTestFacet.class); for (AddonId addonId : addonDependencies.getValue()) { DependencyBuilder dependency = DependencyBuilder.create(addonId.getName()) .setVersion(addonId.getVersion().toString()).setScopeType("test"); if (!dependencyInstaller.isInstalled(project, dependency)) { dependencyInstaller.install(project, dependency); } } return Results .success("Project " + project.getFacet(MetadataFacet.class).getProjectName() + " is now configured for testing"); }
@Override @SuppressWarnings("unchecked") public void start() { getAddonRegistry() .getAddons(addon -> Versions.isSnapshot(addon.getId().getVersion()) && addon.getRepository() instanceof MutableAddonRepository) .stream() .map(Addon::getId) .forEach(addonId -> { // Find local repository path for each addon File installationPath = getInstallationPathFor(addonId); FileResource<?> resource = getResourceFactory().create(FileResource.class, installationPath); ResourceMonitor monitor = resource.monitor(); monitor.addResourceListener(e -> { // Run addonManager.remove and addonManager.install getAddonManager().remove(addonId).perform(); getAddonManager().install(addonId).perform(); }); monitors.put(addonId, monitor); }); }
if (id.getVersion().compareTo(maxAddonId.getVersion()) > 0 && addonAPIVersion.equals(resolver.resolveAPIVersion(id).get()))
private ApplicationReportModel createAboutWindup(GraphContext context, ProjectModel projectModel) { ApplicationReportService applicationReportService = new ApplicationReportService(context); ApplicationReportModel applicationReportModel = applicationReportService.create(); applicationReportModel.setReportPriority(10000); applicationReportModel.setReportName(REPORT_NAME); applicationReportModel.setDescription(REPORT_DESCRIPTION); applicationReportModel.setReportIconClass("fa fa-question-circle"); applicationReportModel.setMainApplicationReport(false); applicationReportModel.setDisplayInApplicationReportIndex(true); if (projectModel == null) applicationReportModel.setDisplayInGlobalApplicationIndex(true); else applicationReportModel.setProjectModel(projectModel); applicationReportModel.setTemplatePath(TEMPLATE_APPLICATION_REPORT); applicationReportModel.setTemplateType(TemplateType.FREEMARKER); Map<String, WindupVertexFrame> related = new HashMap<>(); AboutWindupModel aboutWindupModel = context.getFramed().addFramedVertex(AboutWindupModel.class); aboutWindupModel.setWindupRuntimeVersion(addon.getId().getVersion().toString()); related.put("windupAbout", aboutWindupModel); applicationReportModel.setRelatedResource(related); // Set the filename for the report ReportService reportService = new ReportService(context); String filename = projectModel == null ? "about_global" : "about_" + projectModel.getName(); reportService.setUniqueFilename(applicationReportModel, filename, "html"); return applicationReportModel; }
private ApplicationReportModel createAboutWindup(GraphContext context, ProjectModel projectModel) { ApplicationReportService applicationReportService = new ApplicationReportService(context); ApplicationReportModel applicationReportModel = applicationReportService.create(); applicationReportModel.setReportPriority(10000); applicationReportModel.setReportName(REPORT_NAME); applicationReportModel.setDescription(REPORT_DESCRIPTION); applicationReportModel.setReportIconClass("fa fa-question-circle"); applicationReportModel.setMainApplicationReport(false); applicationReportModel.setDisplayInApplicationReportIndex(true); if (projectModel == null) applicationReportModel.setDisplayInGlobalApplicationIndex(true); else applicationReportModel.setProjectModel(projectModel); applicationReportModel.setTemplatePath(TEMPLATE_APPLICATION_REPORT); applicationReportModel.setTemplateType(TemplateType.FREEMARKER); Map<String, WindupVertexFrame> related = new HashMap<>(); AboutWindupModel aboutWindupModel = context.getFramed().addFramedVertex(AboutWindupModel.class); aboutWindupModel.setWindupRuntimeVersion(addon.getId().getVersion().toString()); related.put("windupAbout", aboutWindupModel); applicationReportModel.setRelatedResource(related); // Set the filename for the report ReportService reportService = new ReportService(context); String filename = projectModel == null ? "about_global" : "about_" + projectModel.getName(); reportService.setUniqueFilename(applicationReportModel, filename, "html"); return applicationReportModel; }
@Override public Result execute(UIExecutionContext context) throws Exception { if (!context.getPrompt().promptBoolean( "Are you sure you want to continue? This command will delete current directories: addons, bin, lib, rules/migration-core")) { return Results.fail("Updating distribution was aborted."); } // Find the latest version. Coordinate latestDist = this.updater.getLatestReleaseOf("org.jboss.windup", "windup-distribution"); Version latestVersion = SingleVersion.valueOf(latestDist.getVersion()); Version installedVersion = currentAddon.getId().getVersion(); if (latestVersion.compareTo(installedVersion) <= 0) { return Results.fail(Util.WINDUP_BRAND_NAME_ACRONYM+" CLI is already in the most updated version."); } distUpdater.replaceWindupDirectoryWithDistribution(latestDist); return Results.success("Sucessfully updated "+Util.WINDUP_BRAND_NAME_ACRONYM+" CLI to version " + latestDist.getVersion() + ". Please restart RHAMT CLI."); }