]
fiorenzo pizza commented on FORGE-692:
--------------------------------------
ops!!!
maven plugin: add "add-dependency" command
------------------------------------------
Key: FORGE-692
URL:
https://issues.jboss.org/browse/FORGE-692
Project: Forge
Issue Type: Story
Components: Maven Integration
Reporter: fiorenzo pizza
i think we need a command to add mvn dependency, without create a specific plugin for
that.
somethink like:
maven add-dependency --groupId it.flower --artifactId flowers --version 1.0.1 --scope
PROVIDED
----
my code:
@Command("add-dependency")
public void addDependency(
final PipeOut out,
@Option(description = "the new groupId; for example:
\"org.jboss.forge\"", name = "groupId", required = true) final
String groupId,
@Option(description = "the new artifactId; for example:
\"forge-parent\"", name = "artifactId", required = true) final
String artifactId,
@Option(description = "the new version; for example:
\"1.0.0\"", name = "version", required = false) final String
version,
@Option(description = "Set the scope of the dependency: for example:
\"PROVIDED\"", name = "scope", required = false, defaultValue =
"PROVIDED") final ScopeType scope)
{
Assert.notNull(groupId, "GroupId must not be empty");
Assert.notNull(artifactId, "ArtifactId must not be empty");
MavenCoreFacet mvn = project.getFacet(MavenCoreFacet.class);
Model pom = mvn.getPOM();
org.apache.maven.model.Dependency dependency = new
org.apache.maven.model.Dependency();
dependency.setGroupId(groupId);
dependency.setArtifactId(artifactId);
if (version != null && !artifactId.isEmpty())
dependency.setVersion(version);
if (scope != null)
dependency.setScope(scope.getScope());
else
dependency.setScope(ScopeType.PROVIDED.getScope());
pom.addDependency(dependency);
mvn.setPOM(pom);
out.println("Added dependecy: " + groupId + ":" + artifactId +
":" + version + ":" + scope.getScope());
}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: