Java 类org.apache.maven.plugin.version.PluginVersionRequest 实例源码

项目:xmvn    文件:XMvnPluginVersionResolver.java   
@Override
public PluginVersionResult resolve( PluginVersionRequest request )
{
    RepositorySystemSession session = request.getRepositorySession();
    WorkspaceReader reader = session.getWorkspaceReader();
    List<String> versions =
        reader.findVersions( new DefaultArtifact( request.getGroupId(), request.getArtifactId(),
                                                  Artifact.DEFAULT_EXTENSION, Artifact.DEFAULT_VERSION ) );
    final String version = versions.isEmpty() ? Artifact.DEFAULT_VERSION : versions.iterator().next();
    final ArtifactRepository repository = reader.getRepository();

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

        @Override
        public String getVersion()
        {
            return version;
        }
    };
}
项目:oceano    文件:DefaultPluginVersionResolver.java   
public PluginVersionResult resolve( PluginVersionRequest request )
    throws PluginVersionResolutionException
{
    logger.debug( "Resolving plugin version for " + request.getGroupId() + ":" + request.getArtifactId() );

    PluginVersionResult result = resolveFromProject( request );

    if ( result == null )
    {
        result = resolveFromRepository( request );

        if ( logger.isDebugEnabled() )
        {
            logger.debug( "Resolved plugin version for " + request.getGroupId() + ":" + request.getArtifactId()
                + " to " + result.getVersion() + " from repository " + result.getRepository() );
        }
    }
    else if ( logger.isDebugEnabled() )
    {
        logger.debug( "Resolved plugin version for " + request.getGroupId() + ":" + request.getArtifactId()
            + " to " + result.getVersion() + " from POM " + request.getPom() );
    }

    return result;
}
项目:oceano    文件:DefaultPluginVersionResolver.java   
private PluginVersionResult resolveFromProject( PluginVersionRequest request )
{
    PluginVersionResult result = null;

    if ( request.getPom() != null && request.getPom().getBuild() != null )
    {
        Build build = request.getPom().getBuild();

        result = resolveFromProject( request, build.getPlugins() );

        if ( result == null && build.getPluginManagement() != null )
        {
            result = resolveFromProject( request, build.getPluginManagement().getPlugins() );
        }
    }

    return result;
}
项目:oceano    文件:DefaultPluginVersionResolver.java   
private PluginVersionResult resolveFromProject( PluginVersionRequest request, List<Plugin> plugins )
{
    for ( Plugin plugin : plugins )
    {
        if ( request.getGroupId().equals( plugin.getGroupId() )
            && request.getArtifactId().equals( plugin.getArtifactId() ) )
        {
            if ( plugin.getVersion() != null )
            {
                return new DefaultPluginVersionResult( plugin.getVersion() );
            }
            else
            {
                return null;
            }
        }
    }
    return null;
}
项目:oceano    文件:PluginVersionResolverStub.java   
public PluginVersionResult resolve( PluginVersionRequest request )
    throws PluginVersionResolutionException
{
    return new PluginVersionResult()
    {
        public String getVersion()
        {
            return "0.42";
        }

        public ArtifactRepository getRepository()
        {
            return null;
        }
    };
}
项目:xmvn    文件:PluginVersionResolverTest.java   
@Before
public void setUp()
{
    resolver = new XMvnPluginVersionResolver();

    rq = EasyMock.createMock( PluginVersionRequest.class );
    session = EasyMock.createMock( RepositorySystemSession.class );
    reader = EasyMock.createMock( WorkspaceReader.class );
    repo = new WorkspaceRepository();
}
项目:oceano    文件:MojoDescriptorCreator.java   
private void resolvePluginVersion( Plugin plugin, MavenSession session, MavenProject project )
    throws PluginVersionResolutionException
{
    PluginVersionRequest versionRequest =
        new DefaultPluginVersionRequest( plugin, session.getRepositorySession(),
                                         project.getRemotePluginRepositories() );
    plugin.setVersion( pluginVersionResolver.resolve( versionRequest ).getVersion() );
}