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


Java Dependency.setArtifactId方法代码示例

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


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

示例1: checkModelDependency

import org.netbeans.modules.maven.model.pom.Dependency; //导入方法依赖的package包/类
public static Dependency checkModelDependency(POMModel pom, String groupId, String artifactId, boolean add) {
    Project mdl = pom.getProject();
    Dependency ret = mdl.findDependencyById(groupId, artifactId, null);
    Dependency managed = null;
    if (ret == null || ret.getVersion() == null) {
        //check dependency management section as well..
        DependencyManagement mng = mdl.getDependencyManagement();
        if (mng != null) {
            managed = mng.findDependencyById(groupId, artifactId, null);
        }
    }
    if (add && ret == null) {
        ret = mdl.getModel().getFactory().createDependency();
        ret.setGroupId(groupId);
        ret.setArtifactId(artifactId);
        mdl.addDependency(ret);
    }
    // if managed dependency section is present, return that one for editing..
    return managed == null ? ret : managed;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ModelUtils.java

示例2: addBom

import org.netbeans.modules.maven.model.pom.Dependency; //导入方法依赖的package包/类
private void addBom(JsonNode depsMeta, String bomId) {
    JsonNode bomInfo = depsMeta.path("boms").path(bomId);
    // create dependency management section in pom if missing
    DependencyManagement depMan = model.getProject().getDependencyManagement();
    if (depMan == null) {
        depMan = model.getFactory().createDependencyManagement();
        model.getProject().setDependencyManagement(depMan);
    }
    // add a dependency with type pom and scope import
    Dependency dep = model.getFactory().createDependency();
    dep.setGroupId(bomInfo.path("groupId").asText());
    dep.setArtifactId(bomInfo.path("artifactId").asText());
    dep.setVersion(bomInfo.path("version").asText());
    dep.setType("pom");
    dep.setScope("import");
    depMan.addDependency(dep);
    // bom may require extra repositories
    if (bomInfo.hasNonNull("repositories")) {
        for (JsonNode rep : bomInfo.path("repositories")) {
            addRepository(depsMeta, rep.asText());
            addPluginRepository(depsMeta, rep.asText());
        }
    }
}
 
开发者ID:AlexFalappa,项目名称:nb-springboot,代码行数:25,代码来源:InjectSpringBootGenerator.java

示例3: createDependency

import org.netbeans.modules.maven.model.pom.Dependency; //导入方法依赖的package包/类
private Dependency createDependency(org.apache.maven.model.Dependency source) {
    Dependency target = pomModel.getFactory().createDependency();
    target.setGroupId(source.getGroupId());
    target.setArtifactId(source.getArtifactId());
    target.setClassifier(source.getClassifier());
    if (!"jar".equals(source.getType())) {
        target.setType(source.getType());
    }
    target.setScope(source.getScope());
    return target;
}
 
开发者ID:jeddict,项目名称:jCode,代码行数:12,代码来源:POMManager.java

示例4: addDeps

import org.netbeans.modules.maven.model.pom.Dependency; //导入方法依赖的package包/类
private void addDeps(String bootVersion, final Set<String> selectedDeps) throws Exception {
    logger.log(Level.INFO, "Adding Spring Boot dependencies: {0}", selectedDeps.toString());
    JsonNode depsMeta = InitializrService.getInstance().getDependencies(bootVersion);
    Iterator<Map.Entry<String, JsonNode>> it = depsMeta.path("dependencies").fields();
    int newPos = component.getCaretPosition();
    try {
        if (model.startTransaction()) {
            DependencyContainer container = model.getProject();
            // iterate on "dependencies" JSON object (fields are dependency ids)
            while (it.hasNext()) {
                Map.Entry<String, JsonNode> entry = it.next();
                if (selectedDeps.contains(entry.getKey())) {
                    JsonNode depInfo = entry.getValue();
                    String groupId = depInfo.path("groupId").asText();
                    String artifactId = depInfo.path("artifactId").asText();
                    String scope = depInfo.path("scope").asText();
                    Dependency dep = container.findDependencyById(groupId, artifactId, null);
                    if (dep == null) {
                        dep = model.getFactory().createDependency();
                        dep.setGroupId(groupId);
                        dep.setArtifactId(artifactId);
                        // set scope only if not 'compile'
                        if (!scope.equals("compile")) {
                            if (scope.equals("compileOnly")) {
                                dep.setOptional(Boolean.TRUE);
                            } else {
                                // scope is 'runtime' or 'test'
                                dep.setScope(scope);
                            }
                        }
                        // manage optional version
                        if (depInfo.hasNonNull("version")) {
                            dep.setVersion(depInfo.get("version").asText());
                        }
                        // manage optional need of extra repository
                        if (depInfo.hasNonNull("repository")) {
                            addRepository(depsMeta, depInfo.get("repository").asText());
                            addPluginRepository(depsMeta, depInfo.get("repository").asText());
                        }
                        // manage optional need of BOM inclusion
                        if (depInfo.hasNonNull("bom")) {
                            addBom(depsMeta, depInfo.get("bom").asText());
                        }
                        container.addDependency(dep);
                        newPos = model.getAccess().findPosition(dep.getPeer());
                    }
                }
            }
        }
    } finally {
        try {
            model.endTransaction();
        } catch (IllegalStateException ex) {
            StatusDisplayer.getDefault().setStatusText("Cannot write to the model: " + ex.getMessage(),
                    StatusDisplayer.IMPORTANCE_ERROR_HIGHLIGHT);
        }
    }
    component.setCaretPosition(newPos);
}
 
开发者ID:AlexFalappa,项目名称:nb-springboot,代码行数:60,代码来源:InjectSpringBootGenerator.java


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