@Override public void addPlugin(final MavenPlugin plugin) { addPlugin(plugin, false, null); }
@Override public MavenPlugin getEffectivePlugin(final Coordinate dependency) { return getPlugin(dependency, false, true, null); }
if (managedPlugin && hasManagedPlugin(dependency, profileParam)) pluginToRemove = getManagedPlugin(dependency, profileParam); else if (hasPlugin(dependency)) pluginToRemove = getPlugin(dependency, profileParam); MavenFacet mavenCoreFacet = getFaceted().getFacet(MavenFacet.class); Model pom = mavenCoreFacet.getModel(); BuildBase build = getBuild(pom, profileParam); // We know for sure it isnt null because the plugin exists if (managedPlugin)
@Override public void addPluginRepository(String id, String url, org.jboss.forge.addon.maven.profiles.Profile profileParam) { if (profileParam == null) addPluginRepository(id, url); else { if (!hasPluginRepository(url, profileParam)) { MavenFacet maven = getFaceted().getFacet(MavenFacet.class); Model pom = maven.getModel(); Profile profile = getProfile(pom, profileParam); if (profile == null) { profile = profileParam.getAsMavenProfile(); pom.getProfiles().add(profile); } Repository repo = new Repository(); repo.setId(id); repo.setUrl(url); profile.addPluginRepository(repo); maven.setModel(pom); } } }
private void updatePlugin(final MavenPlugin plugin, boolean managedPlugin, org.jboss.forge.addon.maven.profiles.Profile profileParam) { this.removePlugin(plugin.getCoordinate(), managedPlugin, profileParam); if (!this.hasPlugin(plugin.getCoordinate(), managedPlugin, false, profileParam)) { this.addPlugin(plugin, managedPlugin, profileParam); } } }
@Override public boolean hasPluginRepository(String url, org.jboss.forge.addon.maven.profiles.Profile profileParam) { if (profileParam == null) return hasPluginRepository(url); else { if (url != null) { String trimmedUrl = url.trim(); MavenFacet maven = getFaceted().getFacet(MavenFacet.class); Model pom = maven.getModel(); Profile profile = getProfile(pom, profileParam); if (profile != null) { for (Repository repo : profile.getPluginRepositories()) { if (repo.getUrl().trim().equals(trimmedUrl)) { return true; } } } } return false; } }
@Override public List<DependencyRepository> getPluginRepositories(org.jboss.forge.addon.maven.profiles.Profile profileParam) { if (profileParam == null) return getPluginRepositories(); else { List<DependencyRepository> results = new ArrayList<>(); MavenFacet maven = getFaceted().getFacet(MavenFacet.class); Model pom = maven.getModel(); Profile profile = getProfile(pom, profileParam); if (profile != null) { for (Repository repo : profile.getPluginRepositories()) { results.add(new DependencyRepository(repo.getId(), repo.getUrl())); } } return Collections.unmodifiableList(results); } }
return removePluginRepository(url); else MavenFacet maven = getFaceted().getFacet(MavenFacet.class); Model pom = maven.getModel(); Profile profile = getProfile(pom, profileParam); if (profile != null)
private List<org.apache.maven.model.Plugin> getPluginsPOM(boolean managedPlugin, boolean effectivePlugin, org.jboss.forge.addon.maven.profiles.Profile profileParam) { MavenFacet mavenCoreFacet = getFaceted().getFacet(MavenFacet.class); BuildBase build = getBuild(mavenCoreFacet.getModel(), profileParam); if (build != null) { if (managedPlugin) { PluginManagement pluginManagement = build.getPluginManagement(); if (pluginManagement != null) { return pluginManagement.getPlugins(); } } else { return build.getPlugins(); } } return Collections.emptyList(); }
@Override public void addPluginRepository(final String id, final String url) { if (!hasPluginRepository(url)) { MavenFacet maven = getFaceted().getFacet(MavenFacet.class); Model pom = maven.getModel(); Repository repo = new Repository(); repo.setId(id); repo.setUrl(url); pom.getPluginRepositories().add(repo); maven.setModel(pom); } }
@Override public boolean isInstalled() { return getFaceted().hasFacet(MavenFacet.class); }
private List<MavenPlugin> listConfiguredPlugins(boolean managedPlugin, boolean effectivePlugin, org.jboss.forge.addon.maven.profiles.Profile profileParam) { List<MavenPlugin> plugins = new ArrayList<>(); for (org.apache.maven.model.Plugin plugin : getPluginsPOM(managedPlugin, effectivePlugin, profileParam)) { plugins.add(new MavenPluginAdapter(plugin)); } return plugins; }
Profile profile = getProfile(pom, profileParam); if (profile == null)
private void addPlugin(final MavenPlugin plugin, boolean managedPlugin, org.jboss.forge.addon.maven.profiles.Profile profileParam) { MavenFacet mavenCoreFacet = getFaceted().getFacet(MavenFacet.class); Model pom = mavenCoreFacet.getModel(); BuildBase build = getBuild(pom, profileParam); if (managedPlugin) { PluginManagement pluginManagement = build.getPluginManagement(); if (pluginManagement == null) { pluginManagement = new PluginManagement(); build.setPluginManagement(pluginManagement); } pluginManagement.addPlugin(new MavenPluginAdapter(plugin)); } else { build.addPlugin(new MavenPluginAdapter(plugin)); } mavenCoreFacet.setModel(pom); }
@Override public boolean hasPluginRepository(final String url) { if (url != null) { String trimmedUrl = url.trim(); MavenFacet maven = getFaceted().getFacet(MavenFacet.class); Model pom = maven.getModel(); for (Repository repo : pom.getPluginRepositories()) { if (repo.getUrl().trim().equals(trimmedUrl)) { return true; } } } return false; }
@Override public MavenPlugin getEffectiveManagedPlugin(final Coordinate dependency) { return getPlugin(dependency, true, true, null); }
@Override public void addPlugin(MavenPlugin plugin, org.jboss.forge.addon.maven.profiles.Profile profile) { addPlugin(plugin, false, profile); }
@Override public List<DependencyRepository> getPluginRepositories() { List<DependencyRepository> results = new ArrayList<>(); MavenFacet maven = getFaceted().getFacet(MavenFacet.class); Model pom = maven.getModel(); List<Repository> repos = pom.getPluginRepositories(); if (repos != null) { for (Repository repo : repos) { results.add(new DependencyRepository(repo.getId(), repo.getUrl())); } } return Collections.unmodifiableList(results); }
@Override public MavenPlugin getManagedPlugin(final Coordinate dependency) { return getPlugin(dependency, true, false, null); }
@Override public void addManagedPlugin(final MavenPlugin plugin) { addPlugin(plugin, true, null); }