Package org.apache.maven.project

Examples of org.apache.maven.project.ProjectBuildingRequest


    }

    private void collectProjects( List<MavenProject> projects, List<File> files, MavenExecutionRequest request )
        throws ProjectBuildingException
    {
        ProjectBuildingRequest projectBuildingRequest = request.getProjectBuildingRequest();

        List<ProjectBuildingResult> results = projectBuilder.build( files, request.isRecursive(), projectBuildingRequest );

        boolean problems = false;
View Full Code Here


    }

    private void collectProjects( List<MavenProject> projects, List<File> files, MavenExecutionRequest request )
        throws ProjectBuildingException
    {
        ProjectBuildingRequest projectBuildingRequest = request.getProjectBuildingRequest();

        List<ProjectBuildingResult> results =
            projectBuilder.build( files, request.isRecursive(), projectBuildingRequest );

        boolean problems = false;
View Full Code Here

   {
      PlexusContainer plexus = new PlexusContainer();
      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
View Full Code Here

            MavenExecutionRequestPopulator requestPopulator = plexus.lookup(MavenExecutionRequestPopulator.class);

            requestPopulator.populateFromSettings(executionRequest, settings);
            requestPopulator.populateDefaults(executionRequest);

            ProjectBuildingRequest request = executionRequest.getProjectBuildingRequest();

            org.apache.maven.artifact.repository.ArtifactRepository localRepository = RepositoryUtils
                     .toArtifactRepository("local",
                              new File(settings.getLocalRepository()).toURI().toURL().toString(), null, true, true);
            request.setLocalRepository(localRepository);

            List<org.apache.maven.artifact.repository.ArtifactRepository> settingsRepos = new ArrayList<org.apache.maven.artifact.repository.ArtifactRepository>(
                     request.getRemoteRepositories());
            List<String> activeProfiles = settings.getActiveProfiles();

            Map<String, Profile> profiles = settings.getProfilesAsMap();

            for (String id : activeProfiles)
            {
               Profile profile = profiles.get(id);
               if (profile != null)
               {
                  List<Repository> repositories = profile.getRepositories();
                  for (Repository repository : repositories)
                  {
                     settingsRepos.add(RepositoryUtils.convertFromMavenSettingsRepository(repository));
                  }
               }
            }
            request.setRemoteRepositories(settingsRepos);
            request.setSystemProperties(System.getProperties());

            DefaultRepositorySystemSession repositorySession = MavenRepositorySystemUtils.newSession();
            Proxy activeProxy = settings.getActiveProxy();
            if (activeProxy != null)
            {
               DefaultProxySelector dps = new DefaultProxySelector();
               dps.add(RepositoryUtils.convertFromMavenProxy(activeProxy), activeProxy.getNonProxyHosts());
               repositorySession.setProxySelector(dps);
            }
            LocalRepository localRepo = new LocalRepository(settings.getLocalRepository());

            repositorySession.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManager(repositorySession,
                     localRepo));
            repositorySession.setOffline(settings.isOffline());
            List<Mirror> mirrors = executionRequest.getMirrors();
            if (mirrors != null)
            {
               DefaultMirrorSelector mirrorSelector = new DefaultMirrorSelector();
               for (Mirror mirror : mirrors)
               {
                  mirrorSelector.add(mirror.getId(), mirror.getUrl(), mirror.getLayout(), false, mirror.getMirrorOf(),
                           mirror.getMirrorOfLayouts());
               }
               repositorySession.setMirrorSelector(mirrorSelector);
            }

            request.setRepositorySession(repositorySession);
            request.setProcessPlugins(false);
            request.setResolveDependencies(false);
            this.request = request;
         }
         catch (RuntimeException e)
         {
            throw e;
View Full Code Here

   {
      PlexusContainer plexus = new PlexusContainer();
      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
View Full Code Here

            MavenExecutionRequestPopulator requestPopulator = plexus.lookup(MavenExecutionRequestPopulator.class);

            requestPopulator.populateFromSettings(executionRequest, settings);
            requestPopulator.populateDefaults(executionRequest);

            ProjectBuildingRequest request = executionRequest.getProjectBuildingRequest();

            org.apache.maven.artifact.repository.ArtifactRepository localRepository = RepositoryUtils
                     .toArtifactRepository("local",
                              new File(settings.getLocalRepository()).toURI().toURL().toString(), null, true, true);
            request.setLocalRepository(localRepository);

            List<org.apache.maven.artifact.repository.ArtifactRepository> settingsRepos = new ArrayList<org.apache.maven.artifact.repository.ArtifactRepository>(
                     request.getRemoteRepositories());
            List<String> activeProfiles = settings.getActiveProfiles();

            Map<String, Profile> profiles = settings.getProfilesAsMap();

            for (String id : activeProfiles)
            {
               Profile profile = profiles.get(id);
               if (profile != null)
               {
                  List<Repository> repositories = profile.getRepositories();
                  for (Repository repository : repositories)
                  {
                     settingsRepos.add(RepositoryUtils.convertFromMavenSettingsRepository(repository));
                  }
               }
            }
            request.setRemoteRepositories(settingsRepos);
            request.setSystemProperties(System.getProperties());

            DefaultRepositorySystemSession repositorySession = MavenRepositorySystemUtils.newSession();
            Proxy activeProxy = settings.getActiveProxy();
            if (activeProxy != null)
            {
               DefaultProxySelector dps = new DefaultProxySelector();
               dps.add(RepositoryUtils.convertFromMavenProxy(activeProxy), activeProxy.getNonProxyHosts());
               repositorySession.setProxySelector(dps);
            }
            LocalRepository localRepo = new LocalRepository(settings.getLocalRepository());

            repositorySession.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManager(repositorySession,
                     localRepo));
            repositorySession.setOffline(settings.isOffline());
            List<Mirror> mirrors = executionRequest.getMirrors();
            DefaultMirrorSelector mirrorSelector = new DefaultMirrorSelector();
            if (mirrors != null)
            {
               for (Mirror mirror : mirrors)
               {
                  mirrorSelector.add(mirror.getId(), mirror.getUrl(), mirror.getLayout(), false, mirror.getMirrorOf(),
                           mirror.getMirrorOfLayouts());
               }
            }
            repositorySession.setMirrorSelector(mirrorSelector);
           
            LazyAuthenticationSelector authSelector = new LazyAuthenticationSelector(mirrorSelector);
            for (Server server : settings.getServers())
            {
               authSelector.add(
                        server.getId(),
                        new AuthenticationBuilder().addUsername(server.getUsername()).addPassword(server.getPassword())
                                 .addPrivateKey(server.getPrivateKey(), server.getPassphrase()).build());
            }
            repositorySession.setAuthenticationSelector(authSelector);

            request.setRepositorySession(repositorySession);
            request.setProcessPlugins(false);
            request.setResolveDependencies(false);
            this.request = request;
         }
         catch (RuntimeException e)
         {
            throw e;
View Full Code Here

    @Override
    public File resolve(final MavenProject project, final String artifact) {
        final ArtifactResult result;
        try {
            ProjectBuildingRequest projectBuildingRequest = invoke(project, "getProjectBuildingRequest", ProjectBuildingRequest.class);

            final ArtifactRequest request = new ArtifactRequest();
            final DefaultArtifact defaultArtifact = createArtifact(artifact);
            request.setArtifact(defaultArtifact);
            @SuppressWarnings("unchecked")
View Full Code Here

    @Override
    public File resolve(final MavenProject project, final String artifact) {
        final ArtifactResult result;
        try {
            final ProjectBuildingRequest projectBuildingRequest = invoke(project, "getProjectBuildingRequest", ProjectBuildingRequest.class);
            final ArtifactRequest request = new ArtifactRequest();
            final DefaultArtifact defaultArtifact = createArtifact(artifact);
            request.setArtifact(defaultArtifact);
            @SuppressWarnings("unchecked")
            final List<RemoteRepository> repos = invoke(project, "getRemoteProjectRepositories", List.class);
            request.setRepositories(repos);
            result = repoSystem.resolveArtifact(projectBuildingRequest.getRepositorySession(), request);
        } catch (ArtifactResolutionException e) {
            throw new RuntimeException(e.getMessage(), e);
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e.getMessage(), e);
        } catch (IllegalAccessException e) {
View Full Code Here

   public ProjectBuildingResult getPartialProjectBuildingResult()
   {
      if (this.buildingResult == null)
      {
         ProjectBuildingRequest request = null;
         File pomFile = getPomResource().getUnderlyingResourceObject();
         try
         {
            // Attempt partial build first
            request = getRequest();
            buildingResult = getBuilder().build(pomFile, request);
         }
         catch (ProjectBuildingException partial)
         {
            // try full build if that fails
            if (request != null)
            {
               try
               {
                  request.setResolveDependencies(true);
                  buildingResult = getBuilder().build(pomFile, request);
                  fullBuildingResult = buildingResult;
               }
               catch (Exception full)
               {
View Full Code Here

    */
   public ProjectBuildingResult getFullProjectBuildingResult()
   {
      if (this.fullBuildingResult == null)
      {
         ProjectBuildingRequest request = null;
         request = getRequest();
         File pomFile = getPomResource().getUnderlyingResourceObject();
         if (request != null)
         {
            try
            {
               request.setResolveDependencies(true);
               buildingResult = getBuilder().build(pomFile, request);
               fullBuildingResult = buildingResult;
            }
            catch (Exception full)
            {
View Full Code Here

TOP

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

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.