Skip to content

Commit

Permalink
Remove references to deprecated method of project facade
Browse files Browse the repository at this point in the history
  • Loading branch information
laeubi committed Nov 10, 2022
1 parent bc760a8 commit ad43099
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ public IStatus runInWorkspace(IProgressMonitor monitor) {
private void changeNature(final IProject project, IProgressMonitor monitor) throws CoreException {
IProjectConfigurationManager configurationManager = MavenPlugin.getProjectConfigurationManager();

final ResolverConfiguration configuration = configurationManager.getResolverConfiguration(project);
final ResolverConfiguration configuration = new ResolverConfiguration(
configurationManager.getProjectConfiguration(project));

boolean updateSourceFolders = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public boolean test(Object receiver, String property, Object[] args, Object expe
IMavenProjectRegistry projectManager = MavenPlugin.getMavenProjectRegistry();
IMavenProjectFacade projectFacade = projectManager.create(projectAdapter, new NullProgressMonitor());
if(projectFacade != null) {
IProjectConfiguration configuration = projectFacade.getResolverConfiguration();
IProjectConfiguration configuration = projectFacade.getConfiguration();
return !configuration.isResolveWorkspaceProjects();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ public void setTarget(final IProject project) {
MavenProject mavenProject = facade.getMavenProject(monitor1);
List<MojoExecution> mojoExecutions = ((MavenProjectFacade) facade).getMojoExecutions(monitor1);
LifecycleMappingResult mappingResult = LifecycleMappingFactory.calculateLifecycleMapping(mavenProject,
mojoExecutions, facade.getResolverConfiguration().getLifecycleMappingId(), monitor1);
mojoExecutions, facade.getConfiguration().getLifecycleMappingId(), monitor1);
Map<MojoExecutionKey, List<IPluginExecutionMetadata>> result = mappingResult.getMojoExecutionMapping();
Map<String, List<MojoExecutionKey>> phases = new LinkedHashMap<>();
if(result != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public boolean performOk() {
return false;
}

final ResolverConfiguration configuration = getResolverConfiguration();
final ResolverConfiguration configuration = new ResolverConfiguration(getResolverConfiguration());
if(configuration.getSelectedProfiles().equals(selectedProfilesText.getText()) &&
// configuration.shouldIncludeModules()==includeModulesButton.getSelection() &&
configuration.isResolveWorkspaceProjects() == resolveWorspaceProjectsButton.getSelection()) {
Expand Down Expand Up @@ -165,9 +165,9 @@ public IStatus runInWorkspace(IProgressMonitor monitor) {
return isSet;
}

private ResolverConfiguration getResolverConfiguration() {
private IProjectConfiguration getResolverConfiguration() {
IProjectConfigurationManager projectManager = MavenPlugin.getProjectConfigurationManager();
return projectManager.getResolverConfiguration(getProject());
return projectManager.getProjectConfiguration(getProject());
}

private IProject getProject() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public final T execute(final int kind, final Map<String, String> args, IProgress
return null;
}

IProjectConfiguration resolverConfiguration = configurationManager.getResolverConfiguration(project);
IProjectConfiguration resolverConfiguration = configurationManager.getProjectConfiguration(project);

if(resolverConfiguration == null) {
// TODO unit test me
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ private void updateProjectConfiguration(ProjectConfigurationRequest request, IPr
project.setDefaultCharset(sourceEncoding, monitor);

IMavenExecutionContext executionContext = projectManager.createExecutionContext(mavenProjectFacade.getPom(),
mavenProjectFacade.getResolverConfiguration());
mavenProjectFacade.getConfiguration());

executionContext.execute(mavenProject, (context, m) -> {
ILifecycleMapping lifecycleMapping = getLifecycleMapping(mavenProjectFacade);
Expand Down Expand Up @@ -919,11 +919,35 @@ public ResolverConfiguration getResolverConfiguration(IProject project) {
return ResolverConfigurationIO.readResolverConfiguration(project);
}

/* (non-Javadoc)
* @see org.eclipse.m2e.core.project.IProjectConfigurationManager#getProjectConfiguration(org.eclipse.core.resources.IProject)
*/
@Override
public boolean setResolverConfiguration(IProject project, IProjectConfiguration configuration) {
public IProjectConfiguration getProjectConfiguration(IProject project) {
return ResolverConfigurationIO.readResolverConfiguration(project);
}

@Override
public boolean setResolverConfiguration(IProject project, ResolverConfiguration configuration) {
return ResolverConfigurationIO.saveResolverConfiguration(project, configuration);
}

/* (non-Javadoc)
* @see org.eclipse.m2e.core.project.IProjectConfigurationManager#updateProjectConfiguration(org.eclipse.core.resources.IProject, org.eclipse.m2e.core.project.IProjectConfiguration, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public IStatus updateProjectConfiguration(IProject project, IProjectConfiguration configuration,
IProgressMonitor monitor) {
if(ResolverConfigurationIO.saveResolverConfiguration(project, configuration)) {
try {
updateProjectConfiguration(project, monitor);
} catch(CoreException ex) {
return ex.getStatus();
}
}
return Status.CANCEL_STATUS;
}

/**
* Finds all existing Maven {@link IProject}s to hide from, if "hide folders of nested projects" preference is on,
* else, returns an empty list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void resolveProjectDependencies(final IMavenProjectFacade facade, Set<Cap

markerManager.addMarkers(facade.getPom(), IMavenConstants.MARKER_DEPENDENCY_ID, mavenResult);

if(!facade.getResolverConfiguration().isResolveWorkspaceProjects()) {
if(!facade.getConfiguration().isResolveWorkspaceProjects()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public class MavenProjectFacade implements IMavenProjectFacade, Serializable {

private final File pomFile;

private final ResolverConfiguration resolverConfiguration;
private final IProjectConfiguration resolverConfiguration;

private final long[] timestamp;

Expand Down Expand Up @@ -128,7 +128,7 @@ public class MavenProjectFacade implements IMavenProjectFacade, Serializable {
private transient Map<String, Object> sessionProperties;

public MavenProjectFacade(ProjectRegistryManager manager, IFile pom, MavenProject mavenProject,
ResolverConfiguration resolverConfiguration) {
IProjectConfiguration resolverConfiguration) {
this.manager = manager;
this.pom = pom;
this.pomFile = ProjectRegistryManager.toJavaIoFile(pom);
Expand Down Expand Up @@ -337,7 +337,7 @@ void setMavenProjectArtifacts(MavenProject mavenProject) {

@Override
public ResolverConfiguration getResolverConfiguration() {
return resolverConfiguration;
return new ResolverConfiguration(resolverConfiguration);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public File getWorkspaceStateFile() {
@Override
public <V> V execute(final IMavenProjectFacade facade, final ICallable<V> callable, IProgressMonitor monitor)
throws CoreException {
IMavenExecutionContext context = manager.createExecutionContext(facade.getPom(), facade.getResolverConfiguration());
IMavenExecutionContext context = manager.createExecutionContext(facade.getPom(), facade.getConfiguration());
return context.execute(
(context1, monitor1) -> context1.execute(facade.getMavenProject(monitor1), callable, monitor1), monitor);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ private void refresh(MutableProjectRegistry newState, DependencyResolutionContex

if(newFacade != null) {
MavenProjectFacade facade = newFacade;
IProjectConfiguration resolverConfiguration = facade.getResolverConfiguration();
IProjectConfiguration resolverConfiguration = facade.getConfiguration();
createExecutionContext(newState, pom, resolverConfiguration).execute(getMavenProject(newFacade),
(executionContext, pm) -> {
refreshPhase2(newState, context, originalCapabilities, originalRequirements, pom, facade, pm);
Expand Down Expand Up @@ -603,7 +603,7 @@ void refreshPhase2(MutableProjectRegistry newState, DependencyResolutionContext

private void setupLifecycleMapping(IProgressMonitor monitor, MavenProjectFacade newFacade) throws CoreException {
LifecycleMappingResult mappingResult = LifecycleMappingFactory.calculateLifecycleMapping(getMavenProject(newFacade),
newFacade.getMojoExecutions(), newFacade.getResolverConfiguration().getLifecycleMappingId(), monitor);
newFacade.getMojoExecutions(), newFacade.getConfiguration().getLifecycleMappingId(), monitor);

newFacade.setLifecycleMappingId(mappingResult.getLifecycleMappingId());
Map<MojoExecutionKey, List<IPluginExecutionMetadata>> mojoExecutionMapping = mappingResult
Expand Down Expand Up @@ -823,7 +823,7 @@ public MavenProjectFacade getMavenProject(String groupId, String artifactId, Str

private MavenProject readProjectWithDependencies(IMavenProjectFacade facade) {
IFile pomFile = facade.getPom();
IProjectConfiguration resolverConfiguration = facade.getResolverConfiguration();
IProjectConfiguration resolverConfiguration = facade.getConfiguration();
Collection<MavenExecutionResult> results = readProjectsWithDependencies(pomFile, resolverConfiguration, null);
if(results.size() != 1) {
throw new IllegalStateException("Results should contain one entry.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.ISchedulingRule;

import org.apache.maven.model.Model;
Expand Down Expand Up @@ -62,6 +63,7 @@ void enableMavenNature(IProject project, IProjectConfiguration configuration, IP

void updateProjectConfiguration(IProject project, IProgressMonitor monitor) throws CoreException;

@Deprecated(forRemoval = true)
void updateProjectConfiguration(MavenUpdateRequest request, IProgressMonitor monitor) throws CoreException;

ILifecycleMapping getLifecycleMapping(IMavenProjectFacade projectFacade) throws CoreException;
Expand All @@ -82,14 +84,22 @@ boolean addMavenBuilder(IProject project, IProjectDescription description, IProg
boolean removeMavenBuilder(IProject project, IProjectDescription description, IProgressMonitor monitor)
throws CoreException;

IProjectConfiguration getProjectConfiguration(IProject project);

IStatus updateProjectConfiguration(IProject project, IProjectConfiguration configuration, IProgressMonitor monitor);

/**
* PROVISIONAL
*
* @deprecated use {@link #getProjectConfiguration(IProject)}
*/
@Deprecated(forRemoval = true)
ResolverConfiguration getResolverConfiguration(IProject project);

/**
* PROVISIONAL
*/
boolean setResolverConfiguration(IProject project, IProjectConfiguration configuration);
@Deprecated(forRemoval = true)
boolean setResolverConfiguration(IProject project, ResolverConfiguration configuration);

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ public class ResolverConfiguration implements Serializable, IProjectConfiguratio

private File multiModuleProjectDirectory;

public ResolverConfiguration() {
}

/**
* @param resolverConfiguration
*/
public ResolverConfiguration(IProjectConfiguration resolverConfiguration) {
setLifecycleMappingId(resolverConfiguration.getLifecycleMappingId());
setMultiModuleProjectDirectory(resolverConfiguration.getMultiModuleProjectDirectory());
Properties properties2 = new Properties();
properties2.putAll(resolverConfiguration.getConfigurationProperties());
setProperties(properties2);
setResolveWorkspaceProjects(resolverConfiguration.isResolveWorkspaceProjects());
setSelectedProfiles(resolverConfiguration.getSelectedProfiles());
}

/* (non-Javadoc)
* @see org.eclipse.m2e.core.project.IProjectConfiguration#getProperties()
*/
Expand Down Expand Up @@ -72,9 +88,14 @@ public void setProperties(Properties properties) {
this.properties = properties;
}

/* (non-Javadoc)
* @see org.eclipse.m2e.core.project.IProjectConfiguration#shouldResolveWorkspaceProjects()
/**
* @deprecated use {@link #isResolveWorkspaceProjects()}
*/
@Deprecated(forRemoval = true)
public boolean shouldResolveWorkspaceProjects() {
return isResolveWorkspaceProjects();
}

@Override
public boolean isResolveWorkspaceProjects() {
return this.resolveWorkspaceProjects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ protected void addProjectEntries(Set<IRuntimeClasspathEntry> resolved, IPath pat
return;
}

IProjectConfiguration configuration = projectFacade.getResolverConfiguration();
IProjectConfiguration configuration = projectFacade.getConfiguration();
if(configuration == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private void setProjectConfiguration(ILaunchConfigurationWorkingCopy workingCopy
IFile pomFile = basedir.getFile(new Path(IMavenConstants.POM_FILE_NAME));
IMavenProjectFacade projectFacade = projectManager.create(pomFile, false, new NullProgressMonitor());
if(projectFacade != null) {
IProjectConfiguration configuration = projectFacade.getResolverConfiguration();
IProjectConfiguration configuration = projectFacade.getConfiguration();

String selectedProfiles = configuration.getSelectedProfiles();
if(selectedProfiles != null && selectedProfiles.length() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public void updateActiveProfiles(final IMavenProjectFacade mavenProjectFacade, f
}
IProject project = mavenProjectFacade.getProject();

final ResolverConfiguration configuration = configurationManager.getResolverConfiguration(project);
final ResolverConfiguration configuration = new ResolverConfiguration(
configurationManager.getProjectConfiguration(project));

final String profilesAsString = String.join(", ", profiles);
if(profilesAsString.equals(configuration.getSelectedProfiles())) {
Expand Down Expand Up @@ -135,7 +136,7 @@ public List<ProfileData> getProfileDatas(IMavenProjectFacade facade, IProgressMo
}

IProjectConfiguration resolverConfiguration = MavenPlugin.getProjectConfigurationManager()
.getResolverConfiguration(facade.getProject());
.getProjectConfiguration(facade.getProject());

List<String> configuredProfiles = toList(resolverConfiguration.getSelectedProfiles());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ protected List<MojoExecutionKey> getNotCoveredMojoExecutions(IMavenProjectFacade
protected LifecycleMappingResult calculateLifecycleMapping(MavenProjectFacade facade) throws CoreException {
MavenProject mavenProject = facade.getMavenProject(monitor);
List<MojoExecution> mojoExecutions = facade.getMojoExecutions(monitor);
String lifecycleMappingId = facade.getResolverConfiguration().getLifecycleMappingId();
String lifecycleMappingId = facade.getConfiguration().getLifecycleMappingId();
return LifecycleMappingFactory.calculateLifecycleMapping(mavenProject, mojoExecutions, lifecycleMappingId, monitor);
}

Expand Down

0 comments on commit ad43099

Please sign in to comment.