repositories.add(admin.getLocalRepository());
}
if (!noRemote) {
repositories.addAll(Arrays.asList(admin.listRepositories()));
}
Resolver resolver = admin.resolver(repositories.toArray(new Repository[repositories.size()]));
for (Requirement requirement : parseRequirements(admin, requirements)) {
resolver.add(requirement);
}
if (resolver.resolve(optional ? 0 : Resolver.NO_OPTIONAL_RESOURCES)) {
Resource[] resources;
resources = resolver.getRequiredResources();
if ((resources != null) && (resources.length > 0)) {
System.out.println("Required resource(s):");
printUnderline(System.out, 21);
for (int resIdx = 0; resIdx < resources.length; resIdx++) {
System.out.println(" " + resources[resIdx].getPresentationName() + " (" + resources[resIdx].getVersion() + ")");
if (why) {
Reason[] req = resolver.getReason(resources[resIdx]);
for (int reqIdx = 0; req != null && reqIdx < req.length; reqIdx++) {
if (!req[reqIdx].getRequirement().isOptional()) {
Resource r = req[reqIdx].getResource();
if (r != null) {
System.out.println(" - " + r.getPresentationName() + " / " + req[reqIdx].getRequirement().getName() + ":" + req[reqIdx].getRequirement().getFilter());
} else {
System.out.println(" - " + req[reqIdx].getRequirement().getName() + ":" + req[reqIdx].getRequirement().getFilter());
}
}
}
}
}
}
resources = resolver.getOptionalResources();
if ((resources != null) && (resources.length > 0)) {
System.out.println();
System.out.println("Optional resource(s):");
printUnderline(System.out, 21);
for (int resIdx = 0; resIdx < resources.length; resIdx++) {
System.out.println(" " + resources[resIdx].getPresentationName()
+ " (" + resources[resIdx].getVersion() + ")");
if (why) {
Reason[] req = resolver.getReason(resources[resIdx]);
for (int reqIdx = 0; req != null && reqIdx < req.length; reqIdx++) {
if (!req[reqIdx].getRequirement().isOptional()) {
Resource r = req[reqIdx].getResource();
if (r != null) {
System.out.println(" - " + r.getPresentationName() + " / " + req[reqIdx].getRequirement().getName() + ":" + req[reqIdx].getRequirement().getFilter());
} else {
System.out.println(" - " + req[reqIdx].getRequirement().getName() + ":" + req[reqIdx].getRequirement().getFilter());
}
}
}
}
}
}
if (deploy || start) {
try
{
System.out.print("\nDeploying...");
resolver.deploy(start ? Resolver.START : 0);
System.out.println("done.");
}
catch (IllegalStateException ex)
{
System.err.println(ex);
}
}
} else {
Reason[] reqs = resolver.getUnsatisfiedRequirements();
if ((reqs != null) && (reqs.length > 0)) {
System.out.println("Unsatisfied requirement(s):");
printUnderline(System.out, 27);
for (int reqIdx = 0; reqIdx < reqs.length; reqIdx++) {
System.out.println(" " + reqs[reqIdx].getRequirement().getName() + ":" + reqs[reqIdx].getRequirement().getFilter());