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


Java DependencyManagement类代码示例

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


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

示例1: addBomsWithHigherPrecedence

import org.apache.maven.model.DependencyManagement; //导入依赖的package包/类
public static void addBomsWithHigherPrecedence(Model pomModel, String bomsWithHigherPrecedence) throws IOException {
    DependencyManagement dependencyManagement = pomModel.getDependencyManagement();
    int i = 0;
    String[] boms = StringUtils.commaDelimitedListToStringArray(bomsWithHigherPrecedence);
    for (String bom : boms) {
        String[] coordinates = StringUtils.delimitedListToStringArray(bom, ":");
        if (coordinates.length != 3) {
            throw new IllegalStateException("Coordinates for additional boms are not defined properly.\n" +
                    "It needs to follow a comma separated pattern of groupId:artifactId:version");
        }
        String groupId = coordinates[0];
        String artifactId = coordinates[1];
        String version = coordinates[2];

        Dependency dependency = new Dependency();
        dependency.setGroupId(groupId);
        dependency.setArtifactId(artifactId);
        dependency.setVersion(version);
        dependency.setType("pom");
        dependency.setScope("import");
        dependencyManagement.getDependencies().add(i++, dependency);
    }

    pomModel.setDependencyManagement(dependencyManagement);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-maven-plugin,代码行数:26,代码来源:MavenModelUtils.java

示例2: 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 );
        }
    }
}
 
开发者ID:fedora-java,项目名称:xmvn,代码行数:20,代码来源:DefaultModelProcessor.java

示例3: 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 );
        }
    }
}
 
开发者ID:fedora-java,项目名称:xmvn,代码行数:20,代码来源:DefaultModelProcessor.java

示例4: 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;
}
 
开发者ID:bsorrentino,项目名称:maven-confluence-plugin,代码行数:29,代码来源:ConfluenceDeployMojo.java

示例5: removeDependencyManagement

import org.apache.maven.model.DependencyManagement; //导入依赖的package包/类
/**
 * Remove the Maven dependency from a POM file (in management section).
 * 
 * @param pom
 * @param dependency
 * @throws IOException
 * @throws XmlPullParserException
 */
public static void removeDependencyManagement(File pom, Dependency dependency, Log logger) throws IOException, XmlPullParserException {
	Model model = getModelFromPOM(pom, logger);
	
	DependencyManagement dMgmt = model.getDependencyManagement();
	if (dMgmt == null) {
		model.setDependencyManagement(new DependencyManagement());
		dMgmt = model.getDependencyManagement();
	}
	
	for (Iterator<Dependency> it = dMgmt.getDependencies().iterator(); it.hasNext();){
		if (dependenciesEqual(it.next(), dependency)) {
			it.remove();
		}
	}
	
	writeModelToPOM(model, pom, logger);
}
 
开发者ID:fastconnect,项目名称:tibco-bwmaven,代码行数:26,代码来源:POMManager.java

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

示例7: validate

import org.apache.maven.model.DependencyManagement; //导入依赖的package包/类
private static void validate(final Model model) {
    final List<Dependency> dependencies = model.getDependencies();
    for (final Dependency dependency : dependencies) {
        if (dependency.getVersion() == null) {
            final DependencyManagement dm = model.getDependencyManagement();
            final String version = findVersion(dm, dependency);
            if (version == null) {
                throw new IllegalStateException(
                        "Dependency version not set for '"
                                + dependency.getGroupId() + ":"
                                + dependency.getArtifactId() + "' in '"
                                + model.getGroupId() + ":"
                                + model.getArtifactId() + ":"
                                + model.getVersion() + "'");
            }
            dependency.setVersion(Utils4J.replaceVars(version,
                    createVarMap(model)));
        }
    }
}
 
开发者ID:fuinorg,项目名称:utils4maven,代码行数:21,代码来源:MavenPomReader.java

示例8: injectDependencyDefaults

import org.apache.maven.model.DependencyManagement; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected void injectDependencyDefaults(Dependency[] dependencies) {
	if (dependencies != null) {
		final Map<String, Dependency> dependencyMap = new TreeMap<String, Dependency>();
		for (final Dependency dependency : dependencies) {
			if (dependency.getScope() == null) {
				dependency.setScope(Artifact.SCOPE_RUNTIME);
			}
			dependencyMap.put(dependency.getManagementKey(), dependency);
		}

		final DependencyManagement dependencyManagement = getProject().getDependencyManagement();

		if (dependencyManagement != null) {
			merge(dependencyMap, dependencyManagement.getDependencies());
		}
		merge(dependencyMap, getProjectDependencies());
	}
}
 
开发者ID:highsource,项目名称:maven-jaxb2-plugin,代码行数:20,代码来源:RawXJC2Mojo.java

示例9: 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;
}
 
开发者ID:release-engineering,项目名称:pom-manipulation-ext,代码行数:32,代码来源:Project.java

示例10: 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" ) );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:24,代码来源:MavenProjectTest.java

示例11: 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;
}
 
开发者ID:release-engineering,项目名称:redhat-repository-validator,代码行数:22,代码来源:BomFilterSimple.java

示例12: VersionNode

import org.apache.maven.model.DependencyManagement; //导入依赖的package包/类
/** Creates a new instance of VersionNode */
public VersionNode(NBVersionInfo versionInfo, boolean fromDepMng) {
    super(Children.LEAF, fromDepMng ? Lookups.fixed(versionInfo, new DependencyManagement()) : Lookups.fixed(versionInfo));

    this.nbvi = versionInfo;
    this.fromDepMng = fromDepMng;

    setName(versionInfo.getVersion());

    StringBuilder sb = new StringBuilder();
    if (fromDepMng) {
        sb.append(nbvi.getGroupId());
        sb.append(DELIMITER);
        sb.append(nbvi.getArtifactId());
sb.append(DELIMITER);
    } else {
        sb.append(nbvi.getVersion());
    }
    sb.append(" [ ");
    sb.append(nbvi.getType());
    String classifier = nbvi.getClassifier();
    if (classifier != null) {
        sb.append(",");
        sb.append(classifier);
    }
    sb.append(" ] ");
    String repo = nbvi.getRepoId();
    if (repo != null) {
        sb.append(" - ");
        sb.append(repo);
    }

    setDisplayName(sb.toString());

    setIconBaseWithExtension(IconResources.ICON_DEPENDENCY_JAR);

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:MavenNodeFactory.java

示例13: 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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:DependencyNode.java

示例14: 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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:AddDependencyPanel.java

示例15: 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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:LocationAwareMavenXpp3Writer.java


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