Java Code Examples for org.apache.maven.model.Profile#getDependencyManagement()
The following examples show how to use
org.apache.maven.model.Profile#getDependencyManagement() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Project.java From pom-manipulation-ext with Apache License 2.0 | 6 votes |
/** * 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 Map<Profile, Map<ArtifactRef, Dependency>> getResolvedProfileManagedDependencies( MavenSessionHandler session) throws ManipulationException { Map<Profile, Map<ArtifactRef, Dependency>> resolvedProfileManagedDependencies = new HashMap<>(); for ( final Profile profile : ProfileUtils.getProfiles( session, model ) ) { Map<ArtifactRef, Dependency> profileDeps = new HashMap<>(); final DependencyManagement dm = profile.getDependencyManagement(); if ( dm != null ) { resolveDeps( session, dm.getDependencies(), false, profileDeps ); } resolvedProfileManagedDependencies.put( profile, profileDeps ); } return resolvedProfileManagedDependencies; }
Example 2
Source File: CheckDependencyVersions.java From unleash-maven-plugin with Eclipse Public License 1.0 | 5 votes |
private Set<ArtifactCoordinates> getSnapshotsFromManagement(Profile profile, PomPropertyResolver propertyResolver) { this.log.debug("\t\tChecking managed dependencies of profile '" + profile.getId() + "'"); DependencyManagement dependencyManagement = profile.getDependencyManagement(); if (dependencyManagement != null) { Collection<Dependency> snapshots = Collections2.filter(dependencyManagement.getDependencies(), new IsSnapshotDependency(propertyResolver)); return Sets.newHashSet(Collections2.transform(snapshots, DependencyToCoordinates.INSTANCE)); } return Collections.emptySet(); }
Example 3
Source File: AbstractVersionsStep.java From unleash-maven-plugin with Eclipse Public License 1.0 | 5 votes |
private void setProfilesReactorDependencyManagementVersion(MavenProject project, Document document) { List<Profile> profiles = this.rawModels.getUnchecked(project).getProfiles(); for (Profile profile : profiles) { final String dependenciesPath = "/profiles/profile[id[text()='" + profile.getId() + "']]/dependencyManagement"; DependencyManagement dependencyManagement = profile.getDependencyManagement(); if (dependencyManagement != null) { List<Dependency> dependencies = dependencyManagement.getDependencies(); for (Dependency dependency : dependencies) { trySetDependencyVersionFromReactorProjects(project, document, dependenciesPath, dependency); } } } }
Example 4
Source File: ProjectVersionEnforcingManipulator.java From pom-manipulation-ext with Apache License 2.0 | 4 votes |
/** * For each project in the current build set, reset the version if using project.version */ @Override public Set<Project> applyChanges( final List<Project> projects ) { final ProjectVersionEnforcingState state = session.getState( ProjectVersionEnforcingState.class ); if ( !session.isEnabled() || !session.anyStateEnabled( State.activeByDefault ) || state == null || !state.isEnabled() ) { logger.debug( "Project version enforcement is disabled." ); return Collections.emptySet(); } final Set<Project> changed = new HashSet<>(); for ( final Project project : projects ) { final Model model = project.getModel(); model.getProperties().stringPropertyNames().stream().filter( k -> model.getProperties().getProperty( k ).equals( Version.PROJECT_VERSION ) ). forEach( k -> { logger.debug( "Replacing project.version within properties for project {} with key {}", project, k ); model.getProperties().setProperty( k, project.getVersion() ); changed.add( project ); } ); // TODO: We _could_ change it everywhere but it only really breaks in POM files. if ( model.getPackaging().equals( "pom" ) ) { enforceDependencyProjectVersion( project, model.getDependencies(), changed ); if ( model.getDependencyManagement() != null ) { enforceDependencyProjectVersion( project, model.getDependencyManagement().getDependencies(), changed ); } if ( model.getBuild() != null ) { enforcePluginProjectVersion( project, model.getBuild().getPlugins(), changed ); if ( model.getBuild().getPluginManagement() != null ) { enforcePluginProjectVersion( project, model.getBuild().getPluginManagement().getPlugins(), changed ); } } final List<Profile> profiles = ProfileUtils.getProfiles( session, model); for ( final Profile profile : profiles ) { enforceDependencyProjectVersion( project, profile.getDependencies(), changed ); if ( profile.getDependencyManagement() != null ) { enforceDependencyProjectVersion( project, profile.getDependencyManagement().getDependencies(), changed ); } if ( profile.getBuild() != null ) { enforcePluginProjectVersion( project, profile.getBuild().getPlugins(), changed ); if ( profile.getBuild().getPluginManagement() != null ) { enforcePluginProjectVersion( project, profile.getBuild().getPluginManagement().getPlugins(), changed ); } } } } } if (!changed.isEmpty()) { logger.warn( "Using ${project.version} in pom files may lead to unexpected errors with inheritance." ); } return changed; }