Java Code Examples for org.apache.maven.project.ProjectBuildingRequest#setProcessPlugins()
The following examples show how to use
org.apache.maven.project.ProjectBuildingRequest#setProcessPlugins() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArtifactDependencyIndexCreator.java From netbeans with Apache License 2.0 | 6 votes |
private MavenProject load(ArtifactInfo ai) { try { Artifact projectArtifact = embedder.createArtifact(ai.getGroupId(), ai.getArtifactId(), ai.getVersion(), ai.getPackaging() != null ? ai.getPackaging() : "jar"); ProjectBuildingRequest dpbr = embedder.createMavenExecutionRequest().getProjectBuildingRequest(); //mkleint: remote repositories don't matter we use project embedder. dpbr.setRemoteRepositories(remoteRepos); dpbr.setProcessPlugins(false); dpbr.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL); ProjectBuildingResult res = embedder.buildProject(projectArtifact, dpbr); if (res.getProject() != null) { return res.getProject(); } else { LOG.log(Level.FINER, "No project model from repository for {0}: {1}", new Object[] {ai, res.getProblems()}); } } catch (ProjectBuildingException ex) { LOG.log(Level.FINER, "Failed to load project model from repository for {0}: {1}", new Object[] {ai, ex}); } catch (Exception exception) { LOG.log(Level.FINER, "Failed to load project model from repository for " + ai, exception); } return null; }
Example 2
Source File: RepositoryMavenCPProvider.java From netbeans with Apache License 2.0 | 5 votes |
private MavenProject loadMavenProject(File pom, String groupId, String artifactId, String version) { MavenEmbedder embedder = EmbedderFactory.getProjectEmbedder(); Artifact projectArtifact = embedder.createArtifact(groupId, artifactId, version, "jar"); try { ProjectBuildingRequest dpbr = embedder.createMavenExecutionRequest().getProjectBuildingRequest(); dpbr.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL); dpbr.setProcessPlugins(false); dpbr.setResolveDependencies(true); ArrayList<ArtifactRepository> remoteRepos = new ArrayList<ArtifactRepository>(); //for project embedder doens't matter // remoteRepos = RepositoryPreferences.getInstance().remoteRepositories(); dpbr.setRemoteRepositories(remoteRepos); ProjectBuildingResult res = embedder.buildProject(projectArtifact, dpbr); if (res.getProject() != null) { return res.getProject(); } else { LOG.log(Level.INFO, "No project model from repository for {0}: {1}", new Object[] {projectArtifact, res.getProblems()}); } } catch (ProjectBuildingException ex) { LOG.log(Level.FINER, "Failed to load project model from repository for {0}: {1}", new Object[] {projectArtifact, ex}); } catch (Exception exception) { LOG.log(Level.FINER, "Failed to load project model from repository for " + projectArtifact, exception); } return null; }
Example 3
Source File: DependencyNode.java From netbeans with Apache License 2.0 | 5 votes |
private Relocation getRelocation(org.netbeans.modules.maven.model.pom.Dependency d) { ProjectBuildingRequest dpbr = EmbedderFactory.getProjectEmbedder().createMavenExecutionRequest().getProjectBuildingRequest(); dpbr.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL); dpbr.setProcessPlugins(false); dpbr.setResolveDependencies(false); ArrayList<ArtifactRepository> remoteRepos = new ArrayList<>(); dpbr.setRemoteRepositories(remoteRepos); String groupId = d.getGroupId(); String artifactId = d.getArtifactId(); String version = d.getVersion(); if(groupId != null && !"".equals(groupId.trim()) && artifactId != null && !"".equals(artifactId.trim()) && version != null && !"".equals(version.trim())) { MavenEmbedder embedder = EmbedderFactory.getProjectEmbedder(); Artifact a = embedder.createProjectArtifact(groupId, artifactId, version); try { ProjectBuildingResult r = embedder.buildProject(a, dpbr); DistributionManagement dm = r.getProject().getDistributionManagement(); return dm != null ? dm.getRelocation() : null; } catch (ProjectBuildingException ex) { // just log and hope for the best ... Logger.getLogger(DependencyNode.class.getName()).log(Level.INFO, version, ex); } } return null; }
Example 4
Source File: MavenEmbedder.java From netbeans with Apache License 2.0 | 5 votes |
public ProjectBuildingResult buildProject(Artifact art, ProjectBuildingRequest req) throws ProjectBuildingException { if (req.getLocalRepository() == null) { req.setLocalRepository(getLocalRepository()); } MavenExecutionRequest request = createMavenExecutionRequest(); req.setProcessPlugins(false); req.setRepositorySession(maven.newRepositorySession(request)); ProjectBuildingResult res = projectBuilder.build(art, req); normalizePaths(res.getProject()); return res; }