Skip to content

Commit

Permalink
Separated repository command into one command
Browse files Browse the repository at this point in the history
  • Loading branch information
lincolnthree committed Mar 31, 2011
1 parent b32a548 commit ed10696
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 33 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<junit.version>4.8.1</junit.version>
<log4j.version>1.2.16</log4j.version>
<shrinkwrap.version>1.0.0-alpha-11</shrinkwrap.version>
<shrinkwrap.descriptors.version>0.1.4</shrinkwrap.descriptors.version>
<shrinkwrap.descriptors.version>0.1.6</shrinkwrap.descriptors.version>
<slf4j.version>1.5.10</slf4j.version>
<weld.version>1.1.0.Final</weld.version>
<weld.bom.version>1.1.0.Final</weld.bom.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public enum KnownRepository
CENTRAL("http://repo1.maven.org/maven2/"),
JBOSS_NEXUS("http://repository.jboss.org/nexus/content/groups/public"),
JBOSS_LEGACY("http://repository.jboss.org/maven2"),
JAVA_NET("http://download.java.net/maven/2/"),
CUSTOM(null);
JAVA_NET("http://download.java.net/maven/2/");

private final String url;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,28 +289,26 @@ else if (artifacts.size() > 1)
@Command(value = "mvn-plugin",
help = "Download and install a plugin from a maven repository")
public void installFromMvnRepos(@Option(description = "plugin-identifier", required = true) Dependency dep,
@Option(description = "target repository") KnownRepository repo,
@Option(name = "knownRepo", description = "target repository") KnownRepository repo,
@Option(name = "repoUrl", description = "target repository URL") String repoURL,
final PipeOut out) throws Exception
{
if (KnownRepository.CUSTOM.equals(repo))
if (repoURL != null)
{
installFromMvnRepos(dep, out,
new DependencyRepositoryImpl("custom", shell.prompt("What is the repository URL?")));
new DependencyRepositoryImpl("custom", repoURL));
}
else if (repo == null)
{
List<DependencyRepository> repos = new ArrayList<DependencyRepository>();
for (KnownRepository r : KnownRepository.values())
{
if (!KnownRepository.CUSTOM.equals(r))
{
repos.add(new DependencyRepositoryImpl(r.getId(), r.getUrl()));
}
repos.add(new DependencyRepositoryImpl(r));
}
installFromMvnRepos(dep, out, repos);
}
else
installFromMvnRepos(dep, out, new DependencyRepositoryImpl("custom", repo.getUrl()));
installFromMvnRepos(dep, out, new DependencyRepositoryImpl(repo));
}

@Command(value = "jar-plugin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,38 +335,40 @@ else if (project.hasFacet(facet.getClass()))
/*
* Repositories
*/
@Command("add-repository")
@Command("add-known-repository")
public void repoAdd(
@Option(description = "type...", required = true) final KnownRepository repo,
final PipeOut out)
{
DependencyFacet deps = project.getFacet(DependencyFacet.class);

if (KnownRepository.CUSTOM.equals(repo))
if (deps.hasRepository(repo))
{
String name = shell.prompt("What is the name of the repository?");
String url = shell.prompt("What is the URL of the repository?");
if (deps.hasRepository(url))
{
out.println("Repository exists [" + url + "]");
}
else
{
deps.addRepository(name, url);
out.println("Added repository [" + name + "->" + url + "]");
}
out.println("Repository exists [" + repo.name() + "->" + repo.getUrl() + "]");
}
else
{
if (deps.hasRepository(repo))
{
out.println("Repository exists [" + repo.name() + "->" + repo.getUrl() + "]");
}
else
{
deps.addRepository(repo);
out.println("Added repository [" + repo.name() + "->" + repo.getUrl() + "]");
}
deps.addRepository(repo);
out.println("Added repository [" + repo.name() + "->" + repo.getUrl() + "]");
}
}

@Command("add-repository")
public void repoAdd(
@Option(description = "repository name...", required = true) final String name,
@Option(description = "repository URL...", required = true) final String url,
final PipeOut out)
{
DependencyFacet deps = project.getFacet(DependencyFacet.class);

if (deps.hasRepository(url))
{
out.println("Repository exists [" + url + "]");
}
else
{
deps.addRepository(name, url);
out.println("Added repository [" + name + "->" + url + "]");
}
}

Expand Down

0 comments on commit ed10696

Please sign in to comment.