class MavenEmbedder {

    public MavenProject readProject( final InputStream mavenProjectStream ) throws ProjectBuildingException, MavenEmbedderException {
        ModelSource modelSource = new ModelSource() {
            @Override
            public InputStream getInputStream() {
                return mavenProjectStream;
            }

            @Override
            public String getLocation() {
                return "";
            }
        };

        ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
        try {
            org.eclipse.aether.artifact.Artifact lastArtifact = null;
            do {
                Thread.currentThread().setContextClassLoader(componentProvider.getSystemClassLoader());
                ProjectBuilder projectBuilder = componentProvider.lookup(ProjectBuilder.class);
                // BZ-1007894: Check if added dependencies are resolvable.
                ProjectBuildingResult result = projectBuilder.build(modelSource, getProjectBuildingRequest());
                if (result != null && result.getDependencyResolutionResult() != null && !result.getDependencyResolutionResult().getCollectionErrors().isEmpty()) {
                    // A dependency resolution error has been produced. It can contains some error. Throw the first one to the client, so the user will fix every one sequentially.
                    final Exception depedencyResolutionException = result.getDependencyResolutionResult().getCollectionErrors().get(0);
                    if (depedencyResolutionException instanceof ArtifactDescriptorException) {
                        final org.eclipse.aether.artifact.Artifact artifact = ((ArtifactDescriptorException) depedencyResolutionException).getResult().getArtifact();
                        if (!artifact.equals(lastArtifact)) {
                            tryRemoveLocalArtifact(artifact);
                            lastArtifact = artifact;
                            continue;
                        }
                    }
                    if (depedencyResolutionException != null) {
                        throw new MavenEmbedderException(depedencyResolutionException.getMessage(), depedencyResolutionException);
                    }
                }
                return (result == null || result.getProject() == null ) ? null : result.getProject();
            } while (true);
        } catch ( ComponentLookupException e ) {
            throw new MavenEmbedderException( e.getMessage(), e );
        } finally {
            Thread.currentThread().setContextClassLoader( originalCl );
            try {
                mavenProjectStream.close();
            } catch ( IOException e ) {
            }
        }
    }

    public  MavenEmbedder( MavenRequest mavenRequest );
    public  MavenEmbedder( ClassLoader mavenClassLoader,
                          ClassLoader parent,
                          MavenRequest mavenRequest );
    protected  MavenEmbedder( MavenRequest mavenRequest,
                             ComponentProvider componentProvider );

}