本文整理汇总了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;
}
示例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());
}
}
}
示例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;
}
示例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);
}