Package org.apache.maven.project

Examples of org.apache.maven.project.ProjectBuilder


      List<Dependency> result;
      try
      {
         ProjectBuildingRequest request = getBuildingRequest(plexus);
         request.setResolveDependencies(true);
         ProjectBuilder builder = plexus.lookup(ProjectBuilder.class);
         ProjectBuildingResult build = builder.build(pomFile, request);
         result = build.getDependencyResolutionResult().getDependencies();
      }
      finally
      {
         plexus.shutdown();
View Full Code Here


      List<Dependency> result;
      try
      {
         ProjectBuildingRequest request = getBuildingRequest(plexus);
         request.setResolveDependencies(true);
         ProjectBuilder builder = plexus.lookup(ProjectBuilder.class);
         ProjectBuildingResult build = builder.build(pomFile, request);
         result = build.getDependencyResolutionResult().getDependencies();
      }
      finally
      {
         plexus.shutdown();
View Full Code Here

        };

        ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader( this.plexusContainer.getContainerRealm() );
            ProjectBuilder projectBuilder = 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.
                Exception depedencyResolutionException = result.getDependencyResolutionResult().getCollectionErrors().get(0);
                if (depedencyResolutionException != null) throw new MavenEmbedderException(depedencyResolutionException.getMessage(), depedencyResolutionException);
            }
View Full Code Here

    public List<ProjectBuildingResult> buildProjects( File mavenProject, boolean recursive ) throws ProjectBuildingException, MavenEmbedderException {
        ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader( this.plexusContainer.getContainerRealm() );
            ProjectBuilder projectBuilder = lookup(ProjectBuilder.class);
            return projectBuilder.build( Arrays.asList(mavenProject), recursive, getProjectBuildingRequest() );
        } catch(ComponentLookupException e) {
            throw new MavenEmbedderException(e.getMessage(), e);
        } finally {
            Thread.currentThread().setContextClassLoader( originalCl );
        }
View Full Code Here

    assertTrue(pomFile.exists());

    // create the MavenProject from the pom.xml file
    MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest();
    ProjectBuildingRequest buildingRequest = executionRequest.getProjectBuildingRequest();
    ProjectBuilder projectBuilder = this.lookup(ProjectBuilder.class);
    MavenProject project = projectBuilder.build(pomFile, buildingRequest).getProject();
    assertNotNull(project);

    // copy resources
    File source = new File(projectDirectory, "src/main/resources");
    if (source.exists()) {
View Full Code Here

    }

    private MavenProject buildProject(final CommandContext context) throws Exception {
        assert context != null;

        ProjectBuilder builder = plexus.lookup(ProjectBuilder.class);
        ProjectBuildingRequest request = new DefaultProjectBuildingRequest();

        RepositorySystem rsys = plexus.lookup(RepositorySystem.class);
        request.setLocalRepository(rsys.createDefaultLocalRepository());
        request.setRemoteRepositories(Collections.singletonList(rsys.createDefaultRemoteRepository()));

//        request.setLocalRepository( getLocalRepository() );
//        request.setSystemProperties( getSystemProperties() );
//        request.setUserProperties( getUserProperties() );
//        request.setRemoteRepositories( getRemoteRepositories() );
//        request.setPluginArtifactRepositories( getPluginArtifactRepositories() );
//        request.setRepositoryCache( getRepositoryCache() );
//        request.setOffline( isOffline() );
//        request.setForceUpdate( isUpdateSnapshots() );
//        request.setServers( getServers() );
//        request.setMirrors( getMirrors() );
//        request.setProxies( getProxies() );
//        request.setActiveProfileIds( getActiveProfiles() );
//        request.setInactiveProfileIds( getInactiveProfiles() );
//        request.setProfiles( getProfiles() );
//        request.setProcessPlugins( true );
//        request.setBuildStartTime( getStartTime() );
//        request.setTransferListener( getTransferListener() );

        ProjectBuildingResult result = builder.build(pomFile, request);

        // TODO: Handle problems?

        return result.getProject();
    }
View Full Code Here

    public List<ProjectBuildingResult> buildProjects( File mavenProject, boolean recursive ) throws ProjectBuildingException, MavenEmbedderException {
        ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader( this.plexusContainer.getContainerRealm() );
            ProjectBuilder projectBuilder = lookup( ProjectBuilder.class );
            ProjectBuildingRequest projectBuildingRequest = this.mavenExecutionRequest.getProjectBuildingRequest();

            projectBuildingRequest.setValidationLevel( this.mavenRequest.getValidationLevel() );

            RepositorySystemSession repositorySystemSession = buildRepositorySystemSession();

            projectBuildingRequest.setRepositorySession( repositorySystemSession );

            projectBuildingRequest.setProcessPlugins( this.mavenRequest.isProcessPlugins() );

            projectBuildingRequest.setResolveDependencies( this.mavenRequest.isResolveDependencies() );

            return projectBuilder.build( Arrays.asList(mavenProject), recursive, projectBuildingRequest );
        } catch(ComponentLookupException e) {
            throw new MavenEmbedderException(e.getMessage(), e);
        } finally {
            Thread.currentThread().setContextClassLoader( originalCl );
        }
View Full Code Here

TOP

Related Classes of org.apache.maven.project.ProjectBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.