@Override public boolean isInstalled() { return getFaceted().hasFacet(MavenFacet.class); }
@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 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 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); } }
@Override public DependencyRepository removePluginRepository(final String url) { if (url != null) { MavenFacet maven = getFaceted().getFacet(MavenFacet.class); Model pom = maven.getModel(); List<Repository> repos = pom.getPluginRepositories(); for (Repository repo : repos) { if (repo.getUrl().equals(url.trim())) { repos.remove(repo); maven.setModel(pom); return new DependencyRepository(repo.getId(), repo.getUrl()); } } } return 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); } }
MavenFacet maven = getFaceted().getFacet(MavenFacet.class); Model pom = maven.getModel(); Profile profile = getProfile(pom, profileParam);
@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 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); }
MavenFacet mavenCoreFacet = getFaceted().getFacet(MavenFacet.class); Model pom = mavenCoreFacet.getModel();