@Override public List<String> getCompletionTokens() { MavenCoreFacet mavenCoreFacet = project.getFacet(MavenCoreFacet.class); List<String> profiles = new ArrayList<String>(); List<Profile> profileList = mavenCoreFacet.getPOM().getProfiles(); for (Profile profile : profileList) { profiles.add(profile.getId()); } return profiles; } }
private boolean isInstalled() { MavenCoreFacet mvn = project.getFacet(MavenCoreFacet.class); Model pom = mvn.getPOM(); return getPlugin(pom) != null; }
private void tweakForOpenShift() throws Exception { // Check to see if this is an openshift app if (!(new File(OPEN_SHIFT_CONFIG).exists())) { return; } // NEXUS repository definition is missing for OS apps addNexusRepository(); // update standalone.xml to include switchyard bits addSwitchYardToASConfig(OPEN_SHIFT_CONFIG); // add a build section with the scanner plugins MavenCoreFacet mvn = project.getFacet(MavenCoreFacet.class); Model pom = mvn.getPOM(); List<Profile> profiles = new ArrayList<Profile>(); profiles.add(buildOpenShiftProfile()); pom.setProfiles(profiles); mvn.setPOM(pom); }
private void removeShadePlugin() { MavenCoreFacet mvn = project.getFacet(MavenCoreFacet.class); Model pom = mvn.getPOM(); pom.getBuild().removePlugin(getPlugin(pom)); mvn.setPOM(pom); }
@Command("set-version") public void setVersion(final PipeOut out, @Option(description = "the new version; for example: \"1.0.0.Final\"") final String version) { Assert.notNull(version, "GroupId must not be empty"); MavenCoreFacet mvn = project.getFacet(MavenCoreFacet.class); Model pom = mvn.getPOM(); pom.setVersion(version); mvn.setPOM(pom); out.println("Set version [ " + version + " ]"); }
@Command("set-groupid") public void setGroupId(final PipeOut out, @Option(description = "the new groupId; for example: \"org.jboss.forge\"") final String groupId) { Assert.notNull(groupId, "GroupId must not be empty"); MavenCoreFacet mvn = project.getFacet(MavenCoreFacet.class); Model pom = mvn.getPOM(); pom.setGroupId(groupId); mvn.setPOM(pom); out.println("Set groupId [ " + groupId + " ]"); }
@Command("set-artifactid") public void setArtifactId(final PipeOut out, @Option(description = "the new artifactId; for example: \"forge-shell\"") final String artifactId) { Assert.notNull(artifactId, "GroupId must not be empty"); MavenCoreFacet mvn = project.getFacet(MavenCoreFacet.class); Model pom = mvn.getPOM(); pom.setArtifactId(artifactId); mvn.setPOM(pom); out.println("Set artifactId [ " + artifactId + " ]"); }
@Command("set-name") public void setName(final PipeOut out, @Option(description = "the new name; for example: \"UI-Layer\"") final String name) { Assert.notNull(name, "Name must not be empty"); MavenCoreFacet mvn = project.getFacet(MavenCoreFacet.class); Model pom = mvn.getPOM(); pom.setName(name); mvn.setPOM(pom); out.println("Set name [ " + name + " ]"); }
private void modifyConfiguration(final ModifyNode command) { try { assertInstalled(); MavenCoreFacet mvn = project.getFacet(MavenCoreFacet.class); Model pom = mvn.getPOM(); org.apache.maven.model.Plugin plugin = getPlugin(pom); PluginExecution execution = plugin.getExecutions().get(0); Node configuration = XMLParser.parse(((Xpp3Dom) execution.getConfiguration()).toUnescapedString()); command.modify(configuration); execution.setConfiguration(Xpp3DomBuilder.build(XMLParser.toXMLInputStream(configuration), "UTF-8")); mvn.setPOM(pom); } catch (Exception e) { throw new RuntimeException("Error updating configuration", e); } }
private void install() throws XmlPullParserException, IOException { MavenCoreFacet mvn = project.getFacet(MavenCoreFacet.class); Model pom = mvn.getPOM(); org.apache.maven.model.Plugin plugin = new org.apache.maven.model.Plugin(); plugin.setArtifactId(dep.getArtifactId()); plugin.setGroupId(dep.getGroupId()); plugin.setVersion(dep.getVersion()); Xpp3Dom dom = Xpp3DomBuilder.build(new ByteArrayInputStream("<configuration></configuration>".getBytes()), "UTF-8"); List<PluginExecution> executions = plugin.getExecutions(); PluginExecution execution = new PluginExecution(); execution.setPhase("package"); execution.addGoal("shade"); execution.setConfiguration(dom); executions.add(execution); pom.getBuild().getPlugins().add(plugin); mvn.setPOM(pom); }
Profile buildOpenShiftProfile() throws Exception { Model pom = project.getFacet(MavenCoreFacet.class).getPOM(); Profile profile = new Profile(); profile.setId(OPEN_SHIFT_PROFILE); Build build = new Build(); build.setFinalName(pom.getArtifactId()); profile.setBuild(build); addScannerPlugin(pom, profile); Plugin jarPlugin = new Plugin(); jarPlugin.setGroupId("org.apache.maven.plugins"); jarPlugin.setArtifactId("maven-jar-plugin"); jarPlugin.setVersion("2.3.1"); String pluginConfig = "<configuration>" + "<outputDirectory>deployments</outputDirectory>" + "</configuration>"; Xpp3Dom dom = Xpp3DomBuilder.build(new ByteArrayInputStream(pluginConfig.getBytes()), "UTF-8"); jarPlugin.setConfiguration(dom); build.addPlugin(jarPlugin); return profile; }
try { MavenCoreFacet mvn = project.getFacet(MavenCoreFacet.class); Model pom = mvn.getPOM();
@Command("remove-parent") public void removeParent(final PipeOut out) { MavenCoreFacet mvn = project.getFacet(MavenCoreFacet.class); Model pom = mvn.getPOM(); Parent parent = pom.getParent(); if (parent != null) { String parentId = parent.getGroupId() + ":" + parent.getArtifactId() + ":" + parent.getVersion() + " (" + (parent.getRelativePath() == null ? " " : parent.getRelativePath() + ")"); if (shell.promptBoolean("Are you sure you want to remove all parent information from this project? [ " + parentId + "]", false)) { out.println("Removed parent [ " + parentId + " ]"); pom.setParent(null); mvn.setPOM(pom); } else { out.println("Aborted..."); } } else { out.println("Nothing to remove..."); } }
mvn.setPOM(mvn.getPOM());
Model rootPom = rootProject.getFacet(MavenCoreFacet.class).getPOM(); Dependency projectDependency = DependencyBuilder.create() .setGroupId(rootPom.getGroupId() == null ? rootPom.getParent().getGroupId() : rootPom.getGroupId())
DependencyFacet depFacet = currentProject.getFacet(DependencyFacet.class); Model pom = mavenFacet.getPOM();