Refine search
validateStringNotEmpty( "modelVersion", result, model.getModelVersion() ); validateId( "groupId", result, model.getGroupId() ); validateId( "artifactId", result, model.getArtifactId() ); validateStringNotEmpty( "packaging", result, model.getPackaging() ); validateId( "dependencies.dependency.artifactId", result, d.getArtifactId() ); validateId( "dependencies.dependency.groupId", result, d.getGroupId() ); validateStringNotEmpty( "dependencies.dependency.type", result, d.getType(), d.getManagementKey() ); validateStringNotEmpty( "dependencies.dependency.version", result, d.getVersion(), d.getManagementKey() ); if ( mgmt != null ) for ( Iterator it = mgmt.getDependencies().iterator(); it.hasNext(); )
DefaultModelProblemCollector problems, Collection<String> importIds ) DependencyManagement depMgmt = model.getDependencyManagement(); String importing = model.getGroupId() + ':' + model.getArtifactId() + ':' + model.getVersion(); for ( Iterator<Dependency> it = depMgmt.getDependencies().iterator(); it.hasNext(); ) if ( !"pom".equals( dependency.getType() ) || !"import".equals( dependency.getScope() ) ) String groupId = dependency.getGroupId(); String artifactId = dependency.getArtifactId(); String version = dependency.getVersion(); importMgmt = new DependencyManagement();
@SuppressWarnings( "unchecked" ) private void assembleDependencyManagementInheritance( Model child, Model parent ) { DependencyManagement parentDepMgmt = parent.getDependencyManagement(); DependencyManagement childDepMgmt = child.getDependencyManagement(); if ( parentDepMgmt != null ) { if ( childDepMgmt == null ) { child.setDependencyManagement( parentDepMgmt ); } else { List<Dependency> childDeps = childDepMgmt.getDependencies(); Map<String, Dependency> mappedChildDeps = new TreeMap<>(); for ( Dependency dep : childDeps ) { mappedChildDeps.put( dep.getManagementKey(), dep ); } for ( Dependency dep : parentDepMgmt.getDependencies() ) { if ( !mappedChildDeps.containsKey( dep.getManagementKey() ) ) { childDepMgmt.addDependency( dep ); } } } } }
public static DependencyManagement cloneDependencyManagement( DependencyManagement src ) { if ( src == null ) { return null; } DependencyManagement result = new DependencyManagement(); result.setDependencies( cloneList( src.getDependencies(), DEPENDENCY_CLONER ) ); return result; }
DependencyManagement depMgmt = target.getDependencyManagement(); for ( Dependency dependency : depMgmt.getDependencies() ) dependencies.put( dependency.getManagementKey(), dependency ); depMgmt = new DependencyManagement(); target.setDependencyManagement( depMgmt ); for ( Dependency dependency : source.getDependencies() ) String key = dependency.getManagementKey(); if ( !dependencies.containsKey( key ) ) depMgmt.setDependencies( new ArrayList<>( dependencies.values() ) );
private void fillMissingArtifactVersion(ArtifactItem artifactItem) throws MojoExecutionException { List<Dependency> deps = project.getDependencies(); List<Dependency> depMngt = project.getDependencyManagement() == null ? Collections.<Dependency>emptyList() : project.getDependencyManagement().getDependencies(); if ( !findDependencyVersion( artifactItem, deps, false ) && ( project.getDependencyManagement() == null || !findDependencyVersion( artifactItem, depMngt, false ) ) && !findDependencyVersion( artifactItem, deps, true ) && ( project.getDependencyManagement() == null || !findDependencyVersion( artifactItem, depMngt, true ) ) ) { throw new MojoExecutionException( "Unable to find artifact version of " + artifactItem.getGroupId() + ":" + artifactItem.getArtifactId() + " in either dependency list or in project's dependency management." ); } }
if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() ) useLatestSnapshots( pom, getProject().getDependencyManagement().getDependencies() ); if ( getProject().getDependencies() != null && isProcessingDependencies() ) useLatestSnapshots( pom, getProject().getDependencies() ); if ( getProject().getParent() != null && isProcessingParent() ) Dependency dependency = new Dependency(); dependency.setArtifactId(getProject().getParent().getArtifactId()); dependency.setGroupId(getProject().getParent().getGroupId()); dependency.setVersion(getProject().getParent().getVersion()); dependency.setType("pom"); throw new MojoExecutionException( e.getMessage(), e );
public Model toMavenModel() { Model model = new Model(); model.setBuild(new Build()); model.setDescription(description); model.setUrl(url); model.setName(projectId.getArtifact()); DependencyManagement depMan = new DependencyManagement(); for (Id dep : overrides) { Dependency dependency = new Dependency(); dependency.setGroupId(dep.getGroup()); dependency.setArtifactId(dep.getArtifact()); dependency.setVersion(dep.getVersion()); dependency.setClassifier(dep.getClassifier()); depMan.addDependency(dependency); model.setDependencyManagement(depMan);
project.setModel( model ); project.setOriginalModel( result.getRawModel() ); project.setFile( model.getPomFile() ); DependencyManagement dependencyManagement = project.getDependencyManagement(); if ( ( dependencyManagement != null ) && ( ( dependencyManagement.getDependencies() ) != null ) && ( dependencyManagement.getDependencies().size() > 0 ) ) for ( Dependency d : dependencyManagement.getDependencies() ) map.put( d.getManagementKey(), artifact );
private String determineVersion(ArtifactConfiguration artifact) throws MojoExecutionException { Optional<Artifact> resolvedDependency = project.getArtifacts() .stream() .filter( a -> { if ( project.getDependencyManagement() != null ) { Optional<org.apache.maven.model.Dependency> managed = project.getDependencyManagement() .getDependencies() .stream() .filter( d -> { return Objects.equals( d.getGroupId(), artifact.getGroupId() ) && Objects.equals( d.getArtifactId(), artifact.getArtifactId() ) && Objects.equals( d.getClassifier(), artifact.getClassifier() ) && Objects.equals( d.getType(), artifact.getType() ); } ) throw new MojoExecutionException( "A version must be given for artifact " + artifact.toDependencyString() + ". Either specify one explicitly, add it to the project dependencies" +
collect.setRootArtifact( RepositoryUtils.toArtifact( project.getArtifact() ) ); collect.setRequestContext( "project" ); collect.setRepositories( project.getRemoteProjectRepositories() ); if ( project.getDependencyArtifacts() == null ) for ( Dependency dependency : project.getDependencies() ) if ( StringUtils.isEmpty( dependency.getGroupId() ) || StringUtils.isEmpty( dependency.getArtifactId() ) || StringUtils.isEmpty( dependency.getVersion() ) ) if ( depMgmt != null ) for ( Dependency dependency : depMgmt.getDependencies() )
private Map<String, String> versionMap(Model pom) { Map<String, String> result = new HashMap<>(); pom.getDependencyManagement().getDependencies().forEach((dependency) -> { result.put(dependency.getGroupId() + ":" + dependency.getArtifactId(), dependency.getVersion()); }); return result; }
if ( ( dependencyManagement != null ) && ( ( deps = dependencyManagement.getDependencies() ) != null ) && ( deps.size() > 0 ) ) for ( Iterator i = dependencyManagement.getDependencies().iterator(); i.hasNext(); ) VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() ); Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(), versionRange, d.getType(), d.getClassifier(), d.getScope(),
private void mergeManagedDependencies(Model model, ArtifactRepository localRepository, List parentSearchRepositories) throws ProjectBuildingException DependencyManagement modelDepMgmt = model.getDependencyManagement(); Iterator iter = modelDepMgmt.getDependencies().iterator(); boolean doInclude = false; while (iter.hasNext()) depsMap.put( dep.getManagementKey(), dep ); if ( dep.getType().equals( "pom" ) && Artifact.SCOPE_IMPORT.equals( dep.getScope() ) ) iter = modelDepMgmt.getDependencies().iterator(); if (doInclude) MavenProject project = buildFromRepository(artifact, parentSearchRepositories, localRepository, false); DependencyManagement depMgmt = project.getDependencyManagement(); for ( Iterator it = depMgmt.getDependencies().iterator(); it.hasNext(); ) modelDepMgmt.setDependencies(deps);
properties.getProperty(name)); DefaultArtifact artifact = artifact(bom); if (model.getDependencyManagement() == null) { model.setDependencyManagement(new DependencyManagement()); for (Dependency dependency : model.getDependencyManagement() .getDependencies()) { if (ObjectUtils.nullSafeEquals(artifact.getArtifactId(), dependency.getArtifactId()) && ObjectUtils.nullSafeEquals(artifact.getGroupId(), dependency.getGroupId())) { dependency.setVersion(artifact.getVersion()); model.getDependencyManagement().addDependency(bom(artifact));
Map<ArtifactKey, String> managed = new HashMap<ArtifactKey, String>(); if(mp != null) { DependencyManagement dm = mp.getDependencyManagement(); if(dm != null && dm.getDependencies() != null) { for(Dependency dep : dm.getDependencies()) { ArtifactKey artifactKey = new ArtifactKey(dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), dep.getClassifier()); if(inManagedSection) { for(Dependency dep : mp.getModel().getDependencies()) { artifacts.add(new ArtifactKey(dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), dep.getClassifier()));
@SuppressWarnings("unchecked") private String getDependencyVersionFromDependencyManagementOrThrowExceptionIfNotAvailable(Dependency dep) { DependencyManagement dependencyManagement = project.getDependencyManagement(); if (dependencyManagement != null) { List<Dependency> managedDeps = dependencyManagement.getDependencies(); for (Dependency managedDep : managedDeps) { if (managedDep.getArtifactId().equals(dep.getArtifactId()) && managedDep.getGroupId().equals(dep.getGroupId())) { return managedDep.getVersion(); } } throw new IllegalArgumentException(format( "Unable to determine version for dependency: %s:%s", dep.getGroupId(), dep.getArtifactId())); } else { throw new IllegalArgumentException(format( "Unable to determine version for dependency: %s:%s. DependencyManagement is null", dep.getGroupId(), dep.getArtifactId())); } }
@Override public void validateEffectiveModel( Model m, ModelBuildingRequest request, ModelProblemCollector problems ) validateStringNotEmpty( "modelVersion", problems, Severity.ERROR, Version.BASE, m.getModelVersion(), m ); validateId( "groupId", problems, m.getGroupId(), m ); validateId( "artifactId", problems, m.getArtifactId(), m ); validateStringNotEmpty( "packaging", problems, Severity.ERROR, Version.BASE, m.getPackaging(), m ); if ( mgmt != null ) validateEffectiveDependencies( problems, m, mgmt.getDependencies(), true, request );
private Set<String> getProvidedDependencyManagement(String groupId, String artifactId, String version, Set<String> gaChecked) throws Exception { String ga = groupId + ":" + artifactId; gaChecked.add(ga); Artifact bom = resolveArtifact(groupId, artifactId, version, "pom"); MavenProject bomProject = loadExternalProjectPom(bom.getFile()); Set<String> provided = new HashSet<>(); if (bomProject.getDependencyManagement() != null && bomProject.getDependencyManagement().getDependencies() != null) { for (Dependency dep : bomProject.getDependencyManagement().getDependencies()) { if ("pom".equals(dep.getType()) && "import".equals(dep.getScope())) { String subGa = dep.getGroupId() + ":" + dep.getArtifactId(); if (!gaChecked.contains(subGa)) { Set<String> sub = getProvidedDependencyManagement(dep.getGroupId(), dep.getArtifactId(), resolveVersion(bomProject, dep.getVersion()), gaChecked); provided.addAll(sub); } } else { provided.add(comparisonKey(dep)); } } } return provided; }
log.debug("Attempting to find missing version in {}:{}", item.getGroupId() , item.getArtifactId()); List list = project.getDependencies(); if (dependency.getGroupId().equals(item.getGroupId()) && dependency.getArtifactId().equals(item.getArtifactId()) && dependency.getType().equals(item.getType())) log.debug("Found missing version: {} in dependency list", dependency.getVersion()); list = project.getDependencyManagement().getDependencies();