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


Java Dependency类代码示例

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


Dependency类属于org.netbeans.modules.maven.model.pom包,在下文中一共展示了Dependency类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: visit

import org.netbeans.modules.maven.model.pom.Dependency; //导入依赖的package包/类
@Override
@Messages({"TYPE=Type", "CLASSIFIER=Classifier", "SCOPE=Scope", "EXCLUSIONS=Exclusions", "EXCLUSION=Exclusion"})
public void visit(Dependency target) {
    Dependency t = target;
    assert t != null ? t.isInDocumentModel() : true;
    POMQNames names = parent.getPOMQNames();
    checkChildString(names.GROUPID, GROUPID(), t != null ? t.getGroupId() : null);
    checkChildString(names.ARTIFACTID, ARTIFACTID(), t != null ? t.getArtifactId() : null);
    checkChildString(names.VERSION, VERSION(), t != null ? t.getVersion() : null);
    checkChildString(names.TYPE, TYPE(), t != null ? t.getType() : null);
    checkChildString(names.CLASSIFIER, CLASSIFIER(), t != null ? t.getClassifier() : null);
    checkChildString(names.SCOPE, SCOPE(), t != null ? t.getScope() : null);

    this.<Exclusion>checkListObject(names.EXCLUSIONS, names.EXCLUSION,
            Exclusion.class, EXCLUSIONS(),
            t != null ? t.getExclusions() : null,
            new IdentityKeyGenerator<Exclusion>() {
                @Override
                public String createName(Exclusion c) {
                    return c.getArtifactId() != null ? c.getArtifactId() : EXCLUSION();
                }
            });

    count++;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:POMModelVisitor.java

示例3: fixDependency

import org.netbeans.modules.maven.model.pom.Dependency; //导入依赖的package包/类
private void fixDependency(FixVersionConflictPanel.FixDescription fixContent) {
    if (!model.startTransaction()) {
        return;
    }
    if (model.getProject() == null) {
        Logger.getLogger(FixVersionConflictAction.class.getName()).warning("#238748 we got a graph, but the model turned invalid for some reason. if you have steps to reproduce, please reopen the issue.");
        return; //#238748 not clear under which circumstances we get a graph but invalid model
    }
    try {
        if (fixContent.isSet && fixContent.version2Set != null) {
            Dependency dep = ModelUtils.checkModelDependency(model, nodeArtif.getGroupId(), nodeArtif.getArtifactId(), true);
            dep.setVersion(fixContent.version2Set.toString());
        }
        if (fixContent.isExclude) {
            excludeDepFromModel(node.getImpl(), fixContent.exclusionTargets);
        }
    } finally {
        model.endTransaction();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:FixVersionConflictAction.java

示例4: collectManaged

import org.netbeans.modules.maven.model.pom.Dependency; //导入依赖的package包/类
private Map<String, String> collectManaged(Project prj) {
    NbMavenProject project = prj.getLookup().lookup(NbMavenProject.class);
    @SuppressWarnings("unchecked")
    HashMap<String, String> toRet = new HashMap<String, String>();
    if (project == null) { //#154462
        return toRet;
    }
    org.apache.maven.model.DependencyManagement dm = project.getMavenProject().getDependencyManagement();
    if (dm != null) {
        @SuppressWarnings("unchecked")
        List<org.apache.maven.model.Dependency> plugins = dm.getDependencies();
        for (org.apache.maven.model.Dependency dep : plugins) {
            toRet.put(dep.getGroupId() + ":" + dep.getArtifactId(), dep.getVersion()); //NOI18N
        }
    }
    return toRet;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:OverrideDependencyManagementError.java

示例5: getSelectedDependencies

import org.netbeans.modules.maven.model.pom.Dependency; //导入依赖的package包/类
private static List<Dependency> getSelectedDependencies(POMModel mdl, int start, int end) {
    DocumentComponent comp1 = mdl.findComponent(start);

    POMComponent pc = findEnclosing(comp1);
    List<Dependency> dps = null;
    if (pc instanceof org.netbeans.modules.maven.model.pom.Project) {
        org.netbeans.modules.maven.model.pom.Project modprj = (org.netbeans.modules.maven.model.pom.Project) pc;
        dps = modprj.getDependencies();
    } else if (pc instanceof Profile) {
        Profile prf = (Profile) pc;
        dps = prf.getDependencies();
    }
    if (dps == null) {
        return null;
    }
    return extractSelectedDeps(dps, start, end);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:MoveToDependencyManagementHint.java

示例6: create

import org.netbeans.modules.maven.model.pom.Dependency; //导入依赖的package包/类
@Override
public List<? extends CodeGenerator> create(Lookup context) {
    ArrayList<CodeGenerator> toRet = new ArrayList<>();
    POMModel model = context.lookup(POMModel.class);
    if (model != null) {
        // check if there is already a dependency whose artifactId contains 'spring-boot-starter'
        boolean found = false;
        if (model.getProject().getDependencies() != null) {
            for (Dependency dep : model.getProject().getDependencies()) {
                if (dep.getArtifactId().contains("spring-boot-starter")) {
                    found = true;
                    break;
                }
            }
        }
        if (!found) {
            JTextComponent component = context.lookup(JTextComponent.class);
            toRet.add(new InjectSpringBootGenerator(model, component));
        }
    }
    return toRet;
}
 
开发者ID:AlexFalappa,项目名称:nb-springboot,代码行数:23,代码来源:InjectSpringBootGenerator.java

示例7: 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

示例8: create

import org.netbeans.modules.maven.model.pom.Dependency; //导入依赖的package包/类
@Override
public List<? extends CodeGenerator> create(Lookup context) {
    ArrayList<CodeGenerator> toRet = new ArrayList<>();
    POMModel model = context.lookup(POMModel.class);
    if (model != null) {
        // check if there is at least a dependency whose artifactId contains 'spring-boot-starter'
        boolean found = false;
        if (model.getProject().getDependencies() != null) {
            for (Dependency dep : model.getProject().getDependencies()) {
                if (dep.getArtifactId().contains("spring-boot-starter")) {
                    found = true;
                    break;
                }
            }
        }
        if (found) {
            JTextComponent component = context.lookup(JTextComponent.class);
            toRet.add(new SpringDependenciesGenerator(model, component));
        }
    }
    return toRet;
}
 
开发者ID:AlexFalappa,项目名称:nb-springboot,代码行数:23,代码来源:SpringDependenciesGenerator.java

示例9: addDependency

import org.netbeans.modules.maven.model.pom.Dependency; //导入依赖的package包/类
/**
 * 
 * @param pom       FileObject that represents POM
 * @param group     
 * @param artifact
 * @param version
 * @param type
 * @param scope
 * @param classifier
 * @param acceptNull accept null values to scope,type and classifier.
 *                   If true null values will remove corresponding tag.
 */
public static void addDependency(FileObject pom,
        final String group,
        final String artifact,
        final String version,
        final String type,
        final String scope,
        final String classifier, final boolean acceptNull)
{
    ModelOperation<POMModel> operation = new ModelOperation<POMModel>() {
        private static final String BUNDLE_TYPE = "bundle"; //NOI18N
        @Override
        public void performOperation(POMModel model) {
            Dependency dep = checkModelDependency(model, group, artifact, true);
            dep.setVersion(version);
            if (acceptNull || scope != null) {
                dep.setScope(scope);
            }
            if (acceptNull || (type != null && !BUNDLE_TYPE.equals(type))) {
                dep.setType(type);
            }
            if (acceptNull || classifier != null) {
                dep.setClassifier(classifier);
            }
        }
    };
    Utilities.performPOMModelOperations(pom, Collections.singletonList(operation));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:ModelUtils.java

示例10: addRemoveJAR

import org.netbeans.modules.maven.model.pom.Dependency; //导入依赖的package包/类
private boolean addRemoveJAR(File jar, POMModel mdl, String scope, boolean add) throws IOException {
    if (!add) {
        throw new UnsupportedOperationException("removing JARs not yet supported");
    }
    NBVersionInfo dep = null;
    for (NBVersionInfo _dep : RepositoryQueries.findBySHA1Result(jar, RepositoryPreferences.getInstance().getRepositoryInfos()).getResults()) {
        if (!"unknown.binary".equals(_dep.getGroupId())) {
            dep = _dep;
            break;
        }
    }
    if (dep == null) {
        dep = new NBVersionInfo(null, "unknown.binary", jar.getName().replaceFirst("[.]jar$", ""), "SNAPSHOT", null, null, null, null, null);
        addJarToPrivateRepo(jar, mdl, dep);
    }
    //if not found anywhere, add to a custom file:// based repository structure within the project's directory.
    boolean added = false;
    Dependency dependency = ModelUtils.checkModelDependency(mdl, dep.getGroupId(), dep.getArtifactId(), false);
    if (dependency == null) {
        dependency = ModelUtils.checkModelDependency(mdl, dep.getGroupId(), dep.getArtifactId(), true);
        LOG.log(Level.FINE, "added new dep {0} as {1}", new Object[] {jar, dep});
        added = true;
    }
    if (!Utilities.compareObjects(dep.getVersion(), dependency.getVersion())) {
        dependency.setVersion(dep.getVersion());
        LOG.log(Level.FINE, "upgraded version on {0} as {1}", new Object[] {jar, dep});
        added = true;
    }
    if (!Utilities.compareObjects(scope, dependency.getScope())) {
        dependency.setScope(scope);
        LOG.log(Level.FINE, "changed scope on {0} as {1}", new Object[] {jar, dep});
        added = true;
    }
    return added;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:CPExtender.java

示例11: configureProject

import org.netbeans.modules.maven.model.pom.Dependency; //导入依赖的package包/类
@NbBundle.Messages("remove_junit3_when_adding_testng=Removing JUnit 3.x dependency as TestNG has transitive dependency to JUnit 4.x.")
public void configureProject(FileObject createdFile) {
    ClassPath cp = ClassPath.getClassPath(createdFile, ClassPath.COMPILE);
    FileObject ng = cp.findResource("org.testng.annotations.Test"); //NOI18N
    if (ng == null) {
        final Project p = FileOwnerQuery.getOwner(createdFile);
        FileObject pom = p.getProjectDirectory().getFileObject("pom.xml"); //NOI18N
        ModelOperation<POMModel> operation = new ModelOperation<POMModel>() {
            public @Override
            void performOperation(POMModel model) {
                String groupID = "org.testng"; //NOI18N
                String artifactID = "testng"; //NOI18N
                if (!hasEffectiveDependency(groupID, artifactID, p.getLookup().lookup(NbMavenProject.class))) {
                    fixJUnitDependency(model, p.getLookup().lookup(NbMavenProject.class));
                    Dependency dep = ModelUtils.checkModelDependency(model, groupID, artifactID, true);
                    dep.setVersion("6.8.1"); //NOI18N
                    dep.setScope("test"); //NOI18N
                }
            }
        };
        Utilities.performPOMModelOperations(pom, Collections.singletonList(operation));
        RequestProcessor RP = new RequestProcessor("Configure TestNG project task", 1, true); //NOI18N
        RP.post(new Runnable() {

            public void run() {
                p.getLookup().lookup(NbMavenProject.class).downloadDependencyAndJavadocSource(true);
            }
        });
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:MavenTestNGSupport.java

示例12: hasEffectiveDependency

import org.netbeans.modules.maven.model.pom.Dependency; //导入依赖的package包/类
private boolean hasEffectiveDependency(String groupId, String artifactId, NbMavenProject prj) {
    MavenProject mp = prj.getMavenProject();
    List<org.apache.maven.model.Dependency> dl = new ArrayList<org.apache.maven.model.Dependency>();
    dl.addAll(mp.getDependencies());
    org.apache.maven.model.DependencyManagement dm = mp.getDependencyManagement();
    if (dm != null) {
        dl.addAll(dm.getDependencies());
    }
    for (org.apache.maven.model.Dependency d : dl) {
        if (groupId.equals(d.getGroupId()) && artifactId.equals(d.getArtifactId())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:MavenTestNGSupport.java

示例13: checkDependencyList

import org.netbeans.modules.maven.model.pom.Dependency; //导入依赖的package包/类
private void checkDependencyList(List<Dependency> deps, final POMModel model, List<ErrorDescription> toRet, Map<String, String> managed) {
    if (deps != null) {
        for (final Dependency dep : deps) {
            String ver = dep.getVersion();
            if (ver != null) {
                String art = dep.getArtifactId();
                String gr = dep.getGroupId();
                String key = gr + ":" + art; //NOI18N
                if (managed.keySet().contains(key)) {
                    final String managedver = managed.get(key);
                    Document doc = model.getBaseDocument();
                    final Line[] line = new Line[1];
                    doc.render(new Runnable() {
                        @Override
                        public void run() {
                            int position = dep.findChildElementPosition(model.getPOMQNames().VERSION.getQName());
                            line[0] = NbEditorUtilities.getLine(model.getBaseDocument(), position, false);
                        }
                    });
                    toRet.add(ErrorDescriptionFactory.createErrorDescription(
                        configuration.getSeverity(configuration.getPreferences()).toEditorSeverity(),
                        NbBundle.getMessage(OverrideDependencyManagementError.class, "TXT_OverrideDependencyManagementError", managedver),
                        Collections.<Fix>singletonList(new OverrideFix(dep)),
                        doc, line[0].getLineNumber() + 1));
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:OverrideDependencyManagementError.java

示例14: getErrorsForDocument

import org.netbeans.modules.maven.model.pom.Dependency; //导入依赖的package包/类
@Override
public List<ErrorDescription> getErrorsForDocument(POMModel model, Project prj,
        int selectionStart, int selectionEnd, int caretPosition) {
    List<ErrorDescription> err = new ArrayList<ErrorDescription>();
    if (prj == null) {
        return err;
    }
    DocumentComponent comp1 = model.findComponent(selectionStart);
    DocumentComponent comp2 = model.findComponent(selectionEnd);
    if (comp1 == null || comp2 == null) { //#157213
        return err;
    }
 
    List<Dependency> deps = getSelectedDependencies(model, selectionStart, selectionEnd);
    if (deps != null && !deps.isEmpty()) { //NOI18N
        try {
            Line line = NbEditorUtilities.getLine(model.getBaseDocument(), caretPosition, false);
            err.add(ErrorDescriptionFactory.createErrorDescription(
                    Severity.HINT,
                    NbBundle.getMessage(MoveToDependencyManagementHint.class, "TEXT_MoveToDependencyManagementHint"),
                    Collections.<Fix>singletonList(new MoveFix(selectionStart, selectionEnd, model, prj)),
                    model.getBaseDocument(), line.getLineNumber() + 1));
        } catch (IndexOutOfBoundsException ioob) {
            //#214527
            LOG.log(Level.FINE, "document changed", ioob);
        }
    }
    return err;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:MoveToDependencyManagementHint.java

示例15: extractSelectedDeps

import org.netbeans.modules.maven.model.pom.Dependency; //导入依赖的package包/类
private static List<Dependency> extractSelectedDeps(List<Dependency> dps, int selectionStart, int selectionEnd) {
    List<Dependency> toRet = new ArrayList<Dependency>();
    for (Dependency d : dps) {
        int pos = d.findPosition();
        int endPos = d.findEndPosition();
        if (pos >= selectionStart && endPos <= selectionEnd) {
            if (d.getVersion() != null) {
                toRet.add(d);
            }
        }
    }
    return toRet;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:MoveToDependencyManagementHint.java


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