/*-
 * Copyright (c) 2012-2014 Red Hat, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.fedoraproject.xmvn.connector.aether;

import javax.inject.Named;
import javax.inject.Singleton;

import org.apache.maven.plugin.version.PluginVersionRequest;
import org.apache.maven.plugin.version.PluginVersionResolver;
import org.apache.maven.plugin.version.PluginVersionResult;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.repository.ArtifactRepository;
import org.eclipse.aether.repository.WorkspaceReader;

import org.fedoraproject.xmvn.artifact.Artifact;

/**
 * @author Mikolaj Izdebski
 */
@Named( "default" )
@Singleton
public class XMvnPluginVersionResolver
    implements PluginVersionResolver
{
    @Override
    public PluginVersionResult resolve( PluginVersionRequest request )
    {
        RepositorySystemSession session = request.getRepositorySession();
        WorkspaceReader reader = session.getWorkspaceReader();
        final ArtifactRepository repository = reader.getRepository();

        return new PluginVersionResult()
        {
            @Override
            public ArtifactRepository getRepository()
            {
                return repository;
            }

            @Override
            public String getVersion()
            {
                return Artifact.DEFAULT_VERSION;
            }
        };
    }
}

@@ -646,24 +646,48 @@
 or.aether;%0A%0A
+import java.util.List;%0A%0A
 import javax
@@ -701,16 +701,16 @@
 .Named;%0A
-
 import j
@@ -967,16 +967,68 @@
 ession;%0A
+import org.eclipse.aether.artifact.DefaultArtifact;%0A
 import o
@@ -1550,24 +1550,376 @@
 ceReader();%0A
+        List%3CString%3E versions =%0A            reader.findVersions( new DefaultArtifact( request.getGroupId(), request.getArtifactId(),%0A                                                      Artifact.DEFAULT_EXTENSION, Artifact.DEFAULT_VERSION ) );%0A        final String version = versions.isEmpty() ? Artifact.DEFAULT_VERSION : versions.iterator().next();%0A
         fina
@@ -2270,32 +2270,15 @@
 urn 
-Artifact.DEFAULT_VERSION
+version
 ;%0A  

Implement Maven plugin version resolution