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


Java Dependency类代码示例

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


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

示例1: convert

import org.apache.maven.model.Dependency; //导入依赖的package包/类
public List<Dependency> convert(Conf2ScopeMappingContainer conf2ScopeMappingContainer, Set<Configuration> configurations) {
    Map<ModuleDependency, Set<Configuration>> dependencyToConfigurations = createDependencyToConfigurationsMap(configurations);
    Map<ModuleDependency, Conf2ScopeMapping> dependenciesMap = createDependencyToScopeMap(conf2ScopeMappingContainer, dependencyToConfigurations);
    Map<Dependency, Integer> dependenciesWithPriorities = new LinkedHashMap<Dependency, Integer>();
    for (ModuleDependency dependency : dependenciesMap.keySet()) {
        Conf2ScopeMapping conf2ScopeMapping = dependenciesMap.get(dependency);
        String scope = conf2ScopeMapping.getScope();
        Integer priority = conf2ScopeMapping.getPriority() == null ? 0 : conf2ScopeMapping.getPriority();
        Set<Configuration> dependencyConfigurations = dependencyToConfigurations.get(dependency);
        if (dependency.getArtifacts().size() == 0) {
            addFromDependencyDescriptor(dependenciesWithPriorities, dependency, scope, priority, dependencyConfigurations);
        } else {
            addFromArtifactDescriptor(dependenciesWithPriorities, dependency, scope, priority, dependencyConfigurations);
        }
    }
    return new ArrayList<Dependency>(dependenciesWithPriorities.keySet());
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:DefaultPomDependenciesConverter.java

示例2: createDependency

import org.apache.maven.model.Dependency; //导入依赖的package包/类
private Dependency createDependency( Artifact artifact )
{
    Dependency dep = new Dependency();
    dep.setArtifactId( artifact.getArtifactId() );
    if ( artifact.hasClassifier() )
    {
        dep.setClassifier( artifact.getClassifier() );
    }
    dep.setGroupId( artifact.getGroupId() );
    dep.setOptional( artifact.isOptional() );
    dep.setScope( artifact.getScope() );
    dep.setType( artifact.getType() );
    if ( useBaseVersion )
    {
        dep.setVersion( artifact.getBaseVersion() );
    }
    else
    {
        dep.setVersion( artifact.getVersion() );
    }
    return dep;
}
 
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:23,代码来源:ShadeMojo.java

示例3: addDependency

import org.apache.maven.model.Dependency; //导入依赖的package包/类
private void addDependency(MavenDependencyInternal dependency, String artifactId, String scope, String type, String classifier) {
    Dependency mavenDependency = new Dependency();
    mavenDependency.setGroupId(dependency.getGroupId());
    mavenDependency.setArtifactId(artifactId);
    mavenDependency.setVersion(mapToMavenSyntax(dependency.getVersion()));
    mavenDependency.setType(type);
    mavenDependency.setScope(scope);
    mavenDependency.setClassifier(classifier);

    for (ExcludeRule excludeRule : dependency.getExcludeRules()) {
        Exclusion exclusion = new Exclusion();
        exclusion.setGroupId(GUtil.elvis(excludeRule.getGroup(), "*"));
        exclusion.setArtifactId(GUtil.elvis(excludeRule.getModule(), "*"));
        mavenDependency.addExclusion(exclusion);
    }

    getModel().addDependency(mavenDependency);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:MavenPomFileGenerator.java

示例4: asArtifact

import org.apache.maven.model.Dependency; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public Artifact asArtifact (ProjectBuildingRequest projectBuildingRequest, Dependency dependency) throws MavenExecutionException {
	DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
	coordinate.setGroupId(dependency.getGroupId());
	coordinate.setArtifactId(dependency.getArtifactId());
	coordinate.setVersion(dependency.getVersion());
	coordinate.setExtension(dependency.getType());
	coordinate.setClassifier(dependency.getClassifier());

	ArtifactResult ar;
	try {
		ar = artifactResolver.resolveArtifact(projectBuildingRequest, coordinate);
	} catch (ArtifactResolverException e) {
		throw new MavenExecutionException("Failed to resolve artifact " + coordinate, e);
	}
	return ar.getArtifact();
	
}
 
开发者ID:commsen,项目名称:EM,代码行数:19,代码来源:Dependencies.java

示例5: findConflict

import org.apache.maven.model.Dependency; //导入依赖的package包/类
/**
 * @return 0 -> no conflicts, 1 -> conflict in version, 2 -> conflict in scope
 */
private static int findConflict (List<Dependency> deps, String groupId, String artifactId, String version, String scope) {
    if (deps == null) {
        return 0;
    }
    for (Dependency dep : deps) {
        if (artifactId != null && artifactId.equals(dep.getArtifactId()) &&
                groupId != null && groupId.equals(dep.getGroupId())) {
            if (version != null && !version.equals(dep.getVersion())) {
                return 1;
            }
            if (scope != null) {
                if (!scope.equals(dep.getScope())) {
                    return 2;
                }
            } else if (dep.getScope() != null) {
                return 2;
            }

        }
    }

    return 0;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:AddDependencyPanel.java

示例6: populateArtifactInfo

import org.apache.maven.model.Dependency; //导入依赖的package包/类
@Override public void populateArtifactInfo(ArtifactContext context) throws IOException {
    ArtifactInfo ai = context.getArtifactInfo();
    if (ai.getClassifier() != null) {
        return;
    }
    try {
        MavenProject mp = load(ai);
        if (mp != null) {
            List<Dependency> dependencies = mp.getDependencies();
            LOG.log(Level.FINER, "Successfully loaded project model from repository for {0} with {1} dependencies", new Object[] {ai, dependencies.size()});
            dependenciesByArtifact.put(ai, dependencies);
        }
    } catch (InvalidArtifactRTException ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ArtifactDependencyIndexCreator.java

示例7: findDependencyVersion

import org.apache.maven.model.Dependency; //导入依赖的package包/类
/**
 * Tries to find missing version from a list of dependencies. If found, the
 * artifact is updated with the correct version.
 * 
 * @param artifact
 *            representing configured file.
 * @param list
 *            list of dependencies to search.
 * @param looseMatch
 *            only look at artifactId and groupId
 * @return the found dependency
 */
private boolean findDependencyVersion( ArtifactItem artifact, List list, boolean looseMatch )
{
    boolean result = false;

    for ( int i = 0; i < list.size(); i++ )
    {
        Dependency dependency = (Dependency) list.get( i );
        if ( StringUtils.equals( dependency.getArtifactId(), artifact.getArtifactId() )
            && StringUtils.equals( dependency.getGroupId(), artifact.getGroupId() )
            && ( looseMatch || StringUtils.equals( dependency.getClassifier(), artifact.getClassifier() ) )
            && ( looseMatch || StringUtils.equals( dependency.getType(), artifact.getType() ) ) )
        {

            artifact.setVersion( dependency.getVersion() );

            result = true;
            break;
        }
    }

    return result;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:35,代码来源:AbstractFromConfigurationMojo.java

示例8: getDependencyList

import org.apache.maven.model.Dependency; //导入依赖的package包/类
public List getDependencyList( ArtifactItem item )
{
    Dependency dep = new Dependency();
    dep.setArtifactId( item.getArtifactId() );
    dep.setClassifier( item.getClassifier() );
    dep.setGroupId( item.getGroupId() );
    dep.setType( item.getType() );
    dep.setVersion( "2.0-SNAPSHOT" );

    Dependency dep2 = new Dependency();
    dep2.setArtifactId( item.getArtifactId() );
    dep2.setClassifier( "classifier" );
    dep2.setGroupId( item.getGroupId() );
    dep2.setType( item.getType() );
    dep2.setVersion( "2.1" );

    List list = new ArrayList( 2 );
    list.add( dep2 );
    list.add( dep );

    return list;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:23,代码来源:TestUnpackMojo.java

示例9: getDependencyMgtList

import org.apache.maven.model.Dependency; //导入依赖的package包/类
public List getDependencyMgtList( ArtifactItem item )
{
    Dependency dep = new Dependency();
    dep.setArtifactId( item.getArtifactId() );
    dep.setClassifier( item.getClassifier() );
    dep.setGroupId( item.getGroupId() );
    dep.setType( item.getType() );
    dep.setVersion( "3.0-SNAPSHOT" );

    Dependency dep2 = new Dependency();
    dep2.setArtifactId( item.getArtifactId() );
    dep2.setClassifier( "classifier" );
    dep2.setGroupId( item.getGroupId() );
    dep2.setType( item.getType() );
    dep2.setVersion( "3.1" );

    List list = new ArrayList( 2 );
    list.add( dep2 );
    list.add( dep );

    return list;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:23,代码来源:TestUnpackMojo.java

示例10: retrieveDependencyProjectsRecursively

import org.apache.maven.model.Dependency; //导入依赖的package包/类
private static void retrieveDependencyProjectsRecursively(List<MavenProject> result, MavenProject parent, ProjectBuilder projectBuilder, MavenSession session) {
    result.add(parent);
    List<Dependency> children = parent.getDependencies();
    if (children != null) {
        for (Dependency child : children) {
            if (COMPILE_SCOPE.equals(child.getScope())) {
                ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(session.getProjectBuildingRequest());
                buildingRequest.setProject(null);
                Artifact artifact = convertDependencyToJarArtifact(child);
                try {
                    MavenProject dependencyProject = projectBuilder.build(artifact, buildingRequest).getProject();
                    retrieveDependencyProjectsRecursively(result, dependencyProject, projectBuilder, session);
                } catch (ProjectBuildingException skip) {
                    // no op
                }
            }
        }
    }
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:20,代码来源:MavenUtil.java

示例11: getDependencyInList

import org.apache.maven.model.Dependency; //导入依赖的package包/类
/**
 * Get dependency list from a maven model. Note: This is needed because
 * {@link AbstractArtifactPomOperation#getDependencyInList(List, String, String)}
 * does not accept a version as argument.
 */
private Dependency getDependencyInList(Model model, String groupId, String artifactId, String version) {
    List<Dependency> dependencyList = model.getDependencies();
    if (dependencyList == null || dependencyList.size() == 0) {
        return null;
    }

    Dependency dependency = null;
    for (Dependency d : dependencyList) {
        if (d.getArtifactId().equals(artifactId) && d.getGroupId().equals(groupId)
                && d.getVersion().equals(version)) {
            dependency = d;
            break;
        }
    }

    return dependency;
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:23,代码来源:PomAddDependencyTest.java

示例12: includeDependencies

import org.apache.maven.model.Dependency; //导入依赖的package包/类
protected void includeDependencies() {
    Stream<Artifact> artifacts;

    if (Boolean.TRUE.equals(listAllArtifacts)) {
        artifacts = project.getArtifacts().stream()
            .filter(artifact -> StringUtils.equals(artifact.getScope(), DefaultArtifact.SCOPE_PROVIDED));
    } else {
        artifacts = this.project.getDependencies().stream()
            .filter(dependency -> StringUtils.equals(dependency.getScope(), DefaultArtifact.SCOPE_PROVIDED))
            .map(this::toArtifact);
    }

    artifacts.map(Artifact::getId)
        .sorted()
        .map(io.syndesis.model.Dependency::maven)
        .forEachOrdered(extensionBuilder::addDependency);
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:18,代码来源:GenerateMetadataMojo.java

示例13: addStrategies

import org.apache.maven.model.Dependency; //导入依赖的package包/类
private void addStrategies(Model model) {

        final StrategyDependencyResolver strategyDependencyResolver = new StrategyDependencyResolver(configuration.getCustomStrategies());
        final Map<String, Dependency> dependencies = strategyDependencyResolver.resolveDependencies();
        final List<String> errorMessages = new ArrayList<>();

        configuration.autocorrectStrategies(dependencies.keySet(), errorMessages);
        errorMessages.forEach(msg -> LOGGER.error(msg));
        if (!errorMessages.isEmpty()) {
            throw new IllegalStateException("Unknown strategies (see above). Please refer to http://arquillian.org/smart-testing/#_strategies "
                + "for the list of available strategies.");
        }
        final String[] strategies = configuration.getStrategies();
        Arrays.stream(strategies).forEach(strategy -> {
            final Dependency dependency = dependencies.get(strategy);
            model.addDependency(dependency);
        });
        configuration.loadStrategyConfigurations(strategies);
    }
 
开发者ID:arquillian,项目名称:smart-testing,代码行数:20,代码来源:DependencyResolver.java

示例14: should_create_dependency_from_gav_with_exclusions

import org.apache.maven.model.Dependency; //导入依赖的package包/类
@Test
public void should_create_dependency_from_gav_with_exclusions() {
    // when
    Dependency dependency =
        MavenCoordinatesResolver.createDependencyFromCoordinates(String.join(":", groupId, artifactId, version),
            true);

    // then
    assertThat(dependency)
        .hasGroupId(groupId)
        .hasArtifactId(artifactId)
        .hasVersion(version)
        .hasType("jar")
        .hasClassifier(null)
        .exclusions().hasSize(1);
    Exclusion exclusion = dependency.getExclusions().get(0);
    Assertions.assertThat(exclusion.getGroupId()).isEqualTo("*");
    Assertions.assertThat(exclusion.getArtifactId()).isEqualTo("*");
}
 
开发者ID:arquillian,项目名称:smart-testing,代码行数:20,代码来源:MavenCoordinatesResolverTest.java

示例15: should_create_dependency_from_ga_with_st_version_with_shaded_classifier

import org.apache.maven.model.Dependency; //导入依赖的package包/类
@Test
public void should_create_dependency_from_ga_with_st_version_with_shaded_classifier() {
    // when
    Dependency dependency =
        MavenCoordinatesResolver.createDependencyFromCoordinates(
            String.join(":", groupId, artifactId, "", classifier), false);

    // then
    assertThat(dependency)
        .hasGroupId(groupId)
        .hasArtifactId(artifactId)
        .hasVersion(ExtensionVersion.version().toString())
        .hasType("jar")
        .hasClassifier(classifier)
        .exclusions().isEmpty();
}
 
开发者ID:arquillian,项目名称:smart-testing,代码行数:17,代码来源:MavenCoordinatesResolverTest.java


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