本文整理汇总了Java中org.apache.maven.model.DependencyManagement.getDependencies方法的典型用法代码示例。如果您正苦于以下问题:Java DependencyManagement.getDependencies方法的具体用法?Java DependencyManagement.getDependencies怎么用?Java DependencyManagement.getDependencies使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.model.DependencyManagement
的用法示例。
在下文中一共展示了DependencyManagement.getDependencies方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitDependencyManagement
import org.apache.maven.model.DependencyManagement; //导入方法依赖的package包/类
private void visitDependencyManagement( ModelVisitor visitor, DependencyManagement dependencyManagement )
{
List<Dependency> dependencies = dependencyManagement.getDependencies();
if ( dependencies != null )
{
ListIterator<Dependency> dependencyIterator = dependencies.listIterator();
while ( dependencyIterator.hasNext() )
{
Dependency dependency = dependencyIterator.next();
visitor.visitDependencyManagementDependency( dependency );
visitDependencyManagementDependency( visitor, dependency );
dependency = visitor.replaceDependencyManagementDependency( dependency );
if ( dependency == null )
dependencyIterator.remove();
else
dependencyIterator.set( dependency );
}
}
}
示例2: visitProfileDependencyManagement
import org.apache.maven.model.DependencyManagement; //导入方法依赖的package包/类
private void visitProfileDependencyManagement( ModelVisitor visitor, DependencyManagement dependencyManagement )
{
List<Dependency> dependencies = dependencyManagement.getDependencies();
if ( dependencies != null )
{
ListIterator<Dependency> dependencyIterator = dependencies.listIterator();
while ( dependencyIterator.hasNext() )
{
Dependency dependency = dependencyIterator.next();
visitor.visitProfileDependencyManagementDependency( dependency );
visitProfileDependencyManagementDependency( visitor, dependency );
dependency = visitor.replaceProfileDependencyManagementDependency( dependency );
if ( dependency == null )
dependencyIterator.remove();
else
dependencyIterator.set( dependency );
}
}
}
示例3: createManagedVersionMap
import org.apache.maven.model.DependencyManagement; //导入方法依赖的package包/类
/**
*
* @param projectId
* @param dependencyManagement
* @return
* @throws ProjectBuildingException
*/
private Map createManagedVersionMap(String projectId, DependencyManagement dependencyManagement) throws ProjectBuildingException {
Map map;
if (dependencyManagement != null && dependencyManagement.getDependencies() != null) {
map = new HashMap();
for (Dependency d : dependencyManagement.getDependencies()) {
try {
VersionRange versionRange = VersionRange.createFromVersionSpec(d.getVersion());
Artifact artifact = factory.createDependencyArtifact(d.getGroupId(), d.getArtifactId(),
versionRange, d.getType(), d.getClassifier(),
d.getScope());
map.put(d.getManagementKey(), artifact);
} catch (InvalidVersionSpecificationException e) {
throw new ProjectBuildingException(projectId, "Unable to parse version '" + d.getVersion()
+ "' for dependency '" + d.getManagementKey() + "': " + e.getMessage(), e);
}
}
} else {
map = Collections.EMPTY_MAP;
}
return map;
}
示例4: checkForSubmoduleDependencyManagement
import org.apache.maven.model.DependencyManagement; //导入方法依赖的package包/类
private void checkForSubmoduleDependencyManagement(final MavenProject project, Log log) {
if (projectHasManagedDependencies(project) &&
!ruleIsDefinedInProjectOrNotModuleParent(project, log) &&
!isExcluded(RuleHelper.getProjectIdentifier(project))) {
final DependencyManagement dependencyManagement = project.getOriginalModel().getDependencyManagement();
if (dependencyManagement.getDependencies().size() > 0) {
failureDetected = true;
logHeader(log, "dependency management in sub modules");
for (Dependency dependency : dependencyManagement.getDependencies()) {
log.warn("module '" + project.getArtifact().getDependencyConflictId() + "' has dependency management for: " +
dependency.getManagementKey());
}
}
}
}
开发者ID:1and1,项目名称:ono-extra-enforcer-rules,代码行数:17,代码来源:ForbidDependencyManagementInSubModulesRule.java
示例5: getResolvedProfileManagedDependencies
import org.apache.maven.model.DependencyManagement; //导入方法依赖的package包/类
/**
* This method will scan the dependencies in the dependencyManagement section of the potentially active Profiles in
* this project and return a fully resolved list. Note that while updating the {@link Dependency}
* reference returned will be reflected in the Model as it is the same object, if you wish to remove or add items
* to the Model then you must use {@link #getModel()}
*
* @param session MavenSessionHandler, used by {@link PropertyResolver}
* @return a list of fully resolved {@link ArtifactRef} to the original {@link Dependency} (that were within DependencyManagement)
* @throws ManipulationException if an error occurs
*/
public HashMap<Profile, HashMap<ArtifactRef, Dependency>> getResolvedProfileManagedDependencies( MavenSessionHandler session) throws ManipulationException
{
if ( resolvedProfileManagedDependencies == null )
{
resolvedProfileManagedDependencies = new HashMap<>( );
for ( final Profile profile : ProfileUtils.getProfiles( session, model ) )
{
HashMap<ArtifactRef, Dependency> profileDeps = new HashMap<>();
final DependencyManagement dm = profile.getDependencyManagement();
if ( ! ( dm == null || dm.getDependencies() == null ) )
{
resolveDeps( session, dm.getDependencies(), false, profileDeps );
resolvedProfileManagedDependencies.put( profile, profileDeps );
}
}
}
return resolvedProfileManagedDependencies;
}
示例6: testCloneWithDependencyManagement
import org.apache.maven.model.DependencyManagement; //导入方法依赖的package包/类
public void testCloneWithDependencyManagement()
throws Exception
{
File f = getFileForClasspathResource( "dependencyManagement-pom.xml" );
MavenProject projectToClone = getProjectWithDependencies( f );
DependencyManagement dep = projectToClone.getDependencyManagement();
assertNotNull( "No dependencyManagement", dep );
List<?> list = dep.getDependencies();
assertNotNull( "No dependencies", list );
assertTrue( "Empty dependency list", !list.isEmpty() );
Map<?, ?> map = projectToClone.getManagedVersionMap();
assertNotNull( "No ManagedVersionMap", map );
assertTrue( "ManagedVersionMap is empty", !map.isEmpty() );
MavenProject clonedProject = projectToClone.clone();
assertEquals( "maven-core", clonedProject.getArtifactId() );
Map<?, ?> clonedMap = clonedProject.getManagedVersionMap();
assertNotNull( "ManagedVersionMap not copied", clonedMap );
assertTrue( "ManagedVersionMap is empty", !clonedMap.isEmpty() );
assertTrue( "ManagedVersionMap does not contain test key",
clonedMap.containsKey( "maven-test:maven-test-b:jar" ) );
}
示例7: isBom
import org.apache.maven.model.DependencyManagement; //导入方法依赖的package包/类
@Override
public boolean isBom(Model model) {
if (bomGavPattern != null) {
String gav = model.getId();
if (bomGavPattern.matcher(gav).matches()) {
return true;
}
}
if (model.getPackaging() != null &&
model.getGroupId() != null &&
model.getArtifactId() != null &&
model.getPackaging().equals("pom")) {
if (model.getGroupId().contains("bom") || model.getArtifactId().contains("bom")) {
DependencyManagement depMng = model.getDependencyManagement();
if (depMng != null && depMng.getDependencies() != null && !depMng.getDependencies().isEmpty()) {
return true;
}
}
}
return false;
}
示例8: isManaged
import org.apache.maven.model.DependencyManagement; //导入方法依赖的package包/类
public boolean isManaged() {
DependencyManagement dm = project.getLookup().lookup(NbMavenProject.class).getMavenProject().getDependencyManagement();
if (dm != null) {
List<Dependency> dmList = dm.getDependencies();
for (Dependency d : dmList) {
if (art.getGroupId().equals(d.getGroupId())
&& art.getArtifactId().equals(d.getArtifactId())) {
return true;
}
}
}
return false;
}
示例9: getDependenciesFromDM
import org.apache.maven.model.DependencyManagement; //导入方法依赖的package包/类
private static List<Dependency> getDependenciesFromDM(MavenProject project, Project nbprj) {
NbMavenProjectImpl p = nbprj.getLookup().lookup(NbMavenProjectImpl.class);
MavenProject localProj = project;
DependencyManagement curDM;
List<Dependency> result = new ArrayList<Dependency>();
//mkleint: without the managementKey checks I got some entries multiple times.
// do we actually need to traverse the parent poms, are they completely resolved anyway?
//XXX
Set<String> knownKeys = new HashSet<String>();
while (localProj != null) {
curDM = localProj.getDependencyManagement();
if (curDM != null) {
@SuppressWarnings("unchecked")
List<Dependency> ds = curDM.getDependencies();
for (Dependency d : ds) {
if (knownKeys.contains(d.getManagementKey())) {
continue;
}
result.add(d);
knownKeys.add(d.getManagementKey());
}
}
try {
localProj = p.loadParentOf(EmbedderFactory.getProjectEmbedder(), localProj);
} catch (ProjectBuildingException x) {
break;
}
}
Collections.sort(result, new Comparator<Dependency>() {
@Override
public int compare(Dependency o1, Dependency o2) {
return o1.getManagementKey().compareTo(o2.getManagementKey());
}
});
return result;
}
示例10: writeDependencyManagement
import org.apache.maven.model.DependencyManagement; //导入方法依赖的package包/类
private void writeDependencyManagement(DependencyManagement dependencyManagement, String tagName, XmlSerializer serializer)
throws java.io.IOException {
serializer.startTag(NAMESPACE, tagName);
if ((dependencyManagement.getDependencies() != null) && (dependencyManagement.getDependencies().size() > 0)) {
serializer.startTag(NAMESPACE, "dependencies");
for (Iterator iter = dependencyManagement.getDependencies().iterator(); iter.hasNext();) {
Dependency o = (Dependency) iter.next();
writeDependency(o, "dependency", serializer);
}
serializer.endTag(NAMESPACE, "dependencies");
}
serializer.endTag(NAMESPACE, tagName);
}
示例11: obtainManagedState
import org.apache.maven.model.DependencyManagement; //导入方法依赖的package包/类
private int obtainManagedState(MavenDependencyNode dependencyNode) {
if (proj == null) {
return GraphNode.UNMANAGED;
}
DependencyManagement dm = proj.getDependencyManagement();
if (dm == null) {
return GraphNode.UNMANAGED;
}
@SuppressWarnings("unchecked")
List<Dependency> deps = dm.getDependencies();
if (deps == null) {
return GraphNode.UNMANAGED;
}
Artifact artifact = dependencyNode.getArtifact();
String id = artifact.getArtifactId();
String groupId = artifact.getGroupId();
String version = artifact.getVersion();
for (Dependency dep : deps) {
if (id.equals(dep.getArtifactId()) && groupId.equals(dep.getGroupId())) {
if (!version.equals(dep.getVersion())) {
return GraphNode.OVERRIDES_MANAGED;
} else {
return GraphNode.MANAGED;
}
}
}
return GraphNode.UNMANAGED;
}
示例12: determineDependencies
import org.apache.maven.model.DependencyManagement; //导入方法依赖的package包/类
@Override
protected List<Dependency> determineDependencies(final Model model) {
List<Dependency> dependencies = Collections.emptyList();
final DependencyManagement mgmt = model.getDependencyManagement();
if (mgmt != null) {
dependencies = mgmt.getDependencies();
}
return dependencies;
}
示例13: findVersion
import org.apache.maven.model.DependencyManagement; //导入方法依赖的package包/类
private static String findVersion(final DependencyManagement dm,
final Dependency dep) {
final List<Dependency> dependencies = dm.getDependencies();
for (final Dependency dependency : dependencies) {
if ((dependency.getGroupId().equals(dep.getGroupId()))
&& (dependency.getArtifactId().equals(dep.getArtifactId()))) {
return dependency.getVersion();
}
}
return null;
}
示例14: getProjectDependencyManagement
import org.apache.maven.model.DependencyManagement; //导入方法依赖的package包/类
/**
* Returns all dependencies defined in dependency management of the root pom.
*
* @return
*/
private Set<Artifact> getProjectDependencyManagement() {
Set<Artifact> result = new LinkedHashSet<Artifact>();
DependencyManagement dependencyManagement = getProject().getDependencyManagement();
if (dependencyManagement != null) {
for (Dependency dependency : dependencyManagement.getDependencies()) {
result.add(toArtifact(dependency));
}
}
return result;
}
示例15: createManagedVersionMap
import org.apache.maven.model.DependencyManagement; //导入方法依赖的package包/类
protected Map createManagedVersionMap(String projectId,
DependencyManagement dependencyManagement) throws ProjectBuildingException {
Map map;
if (dependencyManagement != null
&& dependencyManagement.getDependencies() != null) {
map = new HashMap();
for (Iterator i = dependencyManagement.getDependencies().iterator(); i
.hasNext();) {
Dependency d = (Dependency) i.next();
try {
VersionRange versionRange = VersionRange
.createFromVersionSpec(d.getVersion());
Artifact artifact = factory.createDependencyArtifact(d
.getGroupId(), d.getArtifactId(), versionRange, d
.getType(), d.getClassifier(), d.getScope());
map.put(d.getManagementKey(), artifact);
} catch (InvalidVersionSpecificationException e) {
throw new ProjectBuildingException(projectId,
"Unable to parse version '" + d.getVersion()
+ "' for dependency '"
+ d.getManagementKey() + "': "
+ e.getMessage(), e);
}
}
} else {
map = Collections.EMPTY_MAP;
}
return map;
}