本文整理匯總了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());
}
示例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;
}
示例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);
}
示例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();
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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
}
}
}
}
}
示例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;
}
示例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);
}
示例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);
}
示例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("*");
}
示例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();
}