本文整理匯總了Java中org.apache.maven.model.Model.getDependencyManagement方法的典型用法代碼示例。如果您正苦於以下問題:Java Model.getDependencyManagement方法的具體用法?Java Model.getDependencyManagement怎麽用?Java Model.getDependencyManagement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.maven.model.Model
的用法示例。
在下文中一共展示了Model.getDependencyManagement方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: processModules
import org.apache.maven.model.Model; //導入方法依賴的package包/類
public void processModules(ProjectBuildingRequest projectBuildingRequest, MavenProject project) {
String modulesText = project.getProperties().getProperty(PROP_CONTRACTORS);
if (modulesText == null || modulesText.trim().isEmpty()) {
if (Flag.verbose()) {
logger.info("No available modules in '{}'", PROP_CONTRACTORS);
} else if (logger.isDebugEnabled()) {
logger.debug("No available modules in '{}'", PROP_CONTRACTORS);
}
return;
}
String[] modulesArray = modulesText.split("[\\s]*[,\\n][\\s]*");
Set<String> modulesSet = Arrays.stream(modulesArray).collect(Collectors.toSet());
modulesSet.add("com.commsen.em.contractors:em.contractors.runtime:" + VAL_EXTENSION_VERSION);
for (String moduleText : modulesSet) {
String[] coordinates = moduleText.split(":");
if (coordinates.length != 3) {
logger.warn("Invalid maven coordinates for module '{}'! It will be ignored!", moduleText);
continue;
}
Dependency dependency = new Dependency();
dependency.setGroupId(coordinates[0]);
dependency.setArtifactId(coordinates[1]);
dependency.setVersion(coordinates[2]);
dependency.setScope("runtime");
dependency.setType("pom");
try {
Artifact pomArtifact = dependencies.asArtifact(projectBuildingRequest, dependency);
dependency.setType("jar");
MavenXpp3Reader reader = new MavenXpp3Reader();
Model model = reader.read(new FileInputStream(pomArtifact.getFile()));
DependencyManagement dm = model.getDependencyManagement();
if (dm == null) {
dependencies.addToDependencyManagement(project, dependency);
} else {
for (Dependency d : dm.getDependencies()) {
/*
* TODO handle variables properly! For now assume variable is referring to the
* contract's artifact itself (that's what EM contractors do).
*/
if (d.getArtifactId().startsWith("${")) {
dependencies.addToDependencyManagement(project, dependency);
} else {
dependencies.addToDependencyManagement(project, d);
}
}
}
} catch (Exception e) {
logger.warn("Could not process modules from " + coordinates[0] + ":" + coordinates[1] + ":"
+ coordinates[2], e);
}
}
}
示例2: getManagedDependency
import org.apache.maven.model.Model; //導入方法依賴的package包/類
protected Dependency getManagedDependency(Model model, String groupId, String artifactId) {
if (model.getDependencyManagement() == null) {
return null;
}
return getDependencyInList(model.getDependencyManagement().getDependencies(), groupId, artifactId);
}