当前位置: 首页>>代码示例>>Java>>正文


Java ProjectBuildingRequest.setSystemProperties方法代码示例

本文整理汇总了Java中org.apache.maven.project.ProjectBuildingRequest.setSystemProperties方法的典型用法代码示例。如果您正苦于以下问题:Java ProjectBuildingRequest.setSystemProperties方法的具体用法?Java ProjectBuildingRequest.setSystemProperties怎么用?Java ProjectBuildingRequest.setSystemProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.maven.project.ProjectBuildingRequest的用法示例。


在下文中一共展示了ProjectBuildingRequest.setSystemProperties方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildProjects

import org.apache.maven.project.ProjectBuildingRequest; //导入方法依赖的package包/类
private void buildProjects() throws MojoExecutionException {
    final ProjectBuildingRequest request = new DefaultProjectBuildingRequest();
    request.setProcessPlugins(false);
    request.setSystemProperties(System.getProperties());
    request.setRemoteRepositories(this.project.getRemoteArtifactRepositories());
    request.setRepositorySession(this.repositorySystemSession);
    request.setResolveDependencies(true);

    try {
        PROBABLE_FRACTIONS = this.projectBuilder
                .build(Collections.singletonList(findRoot(this.project).getFile()), true, request)
                .stream()
                .filter(this::isNotArquillianArtifact)
                .map(ProjectBuildingResult::getProject)
                .collect(Collectors.toList());
    } catch (ProjectBuildingException e) {
        throw new MojoExecutionException("Error generating list of PROBABLE_FRACTIONS", e);
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm-fraction-plugin,代码行数:20,代码来源:AbstractFractionsMojo.java

示例2: addGav

import org.apache.maven.project.ProjectBuildingRequest; //导入方法依赖的package包/类
/**
 * Find the SCM URL for the given {@code g, a, v} triple and store the association for the later retrieval via
 * {@link #createSortedScmRepositoryMap()}.
 *
 * @param g
 *            {@code groupId}
 * @param a
 *            {@code artifactId}
 * @param v
 *            {@code version}
 * @param failOnUnresolvable
 *            see {@link SrcdepsInitMojo#failOnUnresolvable}
 * @throws MojoExecutionException
 */
public void addGav(String g, String a, String v, boolean failOnUnresolvable) throws MojoExecutionException {
    final Gav gav = new Gav(g, a, v);
    if (!seenGavs.contains(gav)) {
        seenGavs.add(gav);
        final Ga ga = new Ga(g, a);
        log.debug("Adding GA: {}", ga);

        ProjectBuildingRequest projectBuildingRequest = new DefaultProjectBuildingRequest();
        projectBuildingRequest.setLocalRepository(session.getLocalRepository());
        projectBuildingRequest
                .setRemoteRepositories(session.getProjectBuildingRequest().getRemoteRepositories());
        projectBuildingRequest.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);
        projectBuildingRequest.setProcessPlugins(false);
        projectBuildingRequest.setRepositoryMerging(ProjectBuildingRequest.RepositoryMerging.REQUEST_DOMINANT);
        projectBuildingRequest.setSystemProperties(session.getSystemProperties());
        projectBuildingRequest.setRepositorySession(repoSession);

        Artifact pomArtifact = repositorySystem.createProjectArtifact(g, a, v, "compile");
        try {
            ProjectBuildingResult result = projectBuilder.build(pomArtifact, projectBuildingRequest);
            MavenProject dependencyProject = result.getProject();
            ScmUrlAncestry ancestry = ScmUrlAncestry.of(dependencyProject);
            if (!ancestry.hasUrl()) {
                log.warn("No SCM connection for artifact [{}]", ga);
            } else {
                final String url = ancestry.getUrl();
                if (unsupportedUrls.contains(url)) {
                    /* was reported once already */
                } else if (isScmUrlSupported(url)) {
                    log.debug("Found SCM URL [{}] for GA [{}]", url, ga);
                    int len = ancestry.getLength();
                    for (int i = 0; i < len; i++) {
                        this.add(url, ancestry.getGaAt(i));
                    }
                    Set<Ga> rootGas = urlRootGasMap.get(url);
                    if (rootGas == null) {
                        rootGas = new TreeSet<>();
                        urlRootGasMap.put(url, rootGas);
                    }
                    rootGas.add(ancestry.getRootGa());
                } else {
                    log.warn("Unsupported SCM URL [{}] for GAV [{}]", url, ga);
                    unsupportedUrls.add(url);
                }
            }
        } catch (ProjectBuildingException e) {
            final String msg = String.format("Could not resolve [%s] using remote repositories [%s]",
                    pomArtifact, remoteRepos);
            if (failOnUnresolvable) {
                throw new MojoExecutionException(msg, e);
            } else {
                log.warn(msg);
            }
        }
    }
}
 
开发者ID:srcdeps,项目名称:srcdeps-maven,代码行数:71,代码来源:SrcdepsInitMojo.java

示例3: execute

import org.apache.maven.project.ProjectBuildingRequest; //导入方法依赖的package包/类
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    try {
        // find the nar dependency
        Artifact narArtifact = null;
        for (final Artifact artifact : project.getDependencyArtifacts()) {
            if (NAR.equals(artifact.getType())) {
                // ensure the project doesn't have two nar dependencies
                if (narArtifact != null) {
                    throw new MojoExecutionException("Project can only have one NAR dependency.");
                }

                // record the nar dependency
                narArtifact = artifact;
            }
        }

        // ensure there is a nar dependency
        if (narArtifact == null) {
            throw new MojoExecutionException("Project does not have any NAR dependencies.");
        }

        // build the project for the nar artifact
        final ProjectBuildingRequest narRequest = new DefaultProjectBuildingRequest();
        narRequest.setRepositorySession(repoSession);
        narRequest.setSystemProperties(System.getProperties());
        final ProjectBuildingResult narResult = projectBuilder.build(narArtifact, narRequest);

        // get the artifact handler for excluding dependencies
        final ArtifactHandler narHandler = excludesDependencies(narArtifact);
        narArtifact.setArtifactHandler(narHandler);

        // nar artifacts by nature includes dependencies, however this prevents the
        // transitive dependencies from printing using tools like dependency:tree.
        // here we are overriding the artifact handler for all nars so the
        // dependencies can be listed. this is important because nar dependencies
        // will be used as the parent classloader for this nar and seeing what
        // dependencies are provided is critical.
        final Map<String, ArtifactHandler> narHandlerMap = new HashMap<>();
        narHandlerMap.put(NAR, narHandler);
        artifactHandlerManager.addHandlers(narHandlerMap);

        // get the dependency tree
        final DependencyNode root = dependencyTreeBuilder.buildDependencyTree(narResult.getProject(), localRepository, null);

        // write the appropriate output
        DependencyNodeVisitor visitor = null;
        if ("tree".equals(mode)) {
            visitor = new TreeWriter();
        } else if ("pom".equals(mode)) {
            visitor = new PomWriter();
        }

        // ensure the mode was specified correctly
        if (visitor == null) {
            throw new MojoExecutionException("The specified mode is invalid. Supported options are 'tree' and 'pom'.");
        }

        // visit and print the results
        root.accept(visitor);
        getLog().info("--- Provided NAR Dependencies ---\n\n" + visitor.toString());
    } catch (DependencyTreeBuilderException | ProjectBuildingException e) {
        throw new MojoExecutionException("Cannot build project dependency tree", e);
    }
}
 
开发者ID:apache,项目名称:nifi-maven,代码行数:66,代码来源:NarProvidedDependenciesMojo.java


注:本文中的org.apache.maven.project.ProjectBuildingRequest.setSystemProperties方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。