@@ -0,0 +1,2339 @@
+/**%0A * Copyright (c) 2011 RedEngine Ltd, http://www.redengine.co.nz. All rights reserved.%0A *%0A * This program is licensed to you under the Apache License Version 2.0,%0A * and you may not use this file except in compliance with the Apache License Version 2.0.%0A * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.%0A *%0A * Unless required by applicable law or agreed to in writing,%0A * software distributed under the Apache License Version 2.0 is distributed on an%0A * %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.%0A */%0Apackage net.stickycode.stile.sphere;%0A%0Aimport java.util.Collections;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0A%0Aimport javax.inject.Inject;%0A%0Aimport net.stickycode.stile.artifact.Artifact;%0Aimport net.stickycode.stile.artifact.Dependency;%0Aimport net.stickycode.stile.version.Bound;%0Aimport net.stickycode.stile.version.Version;%0A%0Apublic class LowestMatchingVersionDependencyResolver%0A    implements DependencyResolver %7B%0A%0A  @Inject%0A  ArtifactRepository repository;%0A%0A  @Override%0A  public List%3CArtifact%3E resolve(List%3CDependency%3E dependency) %7B%0A    if (dependency.isEmpty())%0A      return Collections.emptyList();%0A    %0A    List%3CArtifact%3E artifacts = new LinkedList%3CArtifact%3E();%0A    for (Dependency d : dependency) %7B%0A      Artifact resolved = resolve(d);%0A      artifacts.add(resolved);%0A      artifacts.addAll(resolve(resolved.getDependencies(Spheres.Main)));%0A    %7D%0A    return artifacts;%0A  %7D%0A%0A  private Artifact resolve(Dependency dependency) %7B%0A    Bound lowerBound = dependency.getVersion().getLowerBound();%0A    if (lowerBound.isExclusive())%0A      throw new RuntimeException(%22Dependency lower bound cannot be exclusive in order to provide stability%22);%0A%0A    Version version = findVersion(dependency, lowerBound);%0A%0A    return repository.load(dependency.getId(), version);%0A  %7D%0A%0A  private Version findVersion(Dependency dependency, Bound lowerBound) %7B%0A    for (Version version : repository.lookupVersions(dependency.getId())) %7B%0A      if (version.equals(lowerBound.getVersion())) %7B%0A        return version;%0A      %7D%0A    %7D%0A%0A    throw new RuntimeException(%22Cant find %22 + dependency.getId() + %22-%22 + lowerBound.getVersion());%0A  %7D%0A%0A%7D%0A

rename class to match implemented interface