Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion org.eclipse.m2e.apt.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.m2e.apt.core;singleton:=true
Bundle-Version: 2.3.100.qualifier
Bundle-Version: 2.3.200.qualifier
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)",
org.eclipse.core.resources,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import org.apache.maven.project.MavenProject;

import org.eclipse.m2e.apt.internal.utils.ProjectUtils;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.configurator.AbstractBuildParticipant;
import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator;
Expand Down Expand Up @@ -351,12 +350,8 @@ protected <T> T getParameterValue(String parameter, Class<T> asType, MojoExecuti
throws CoreException {
PluginExecution execution = new PluginExecution();
execution.setConfiguration(mojoExecution.getConfiguration());
MavenProject mavenProject = mavenFacade.getMavenProject();
return mavenFacade.createExecutionContext().execute(mavenProject, (context, monitor) -> {
//TODO provide as part of the execution context? We then probably won't need the project parameter at all?
return MavenPlugin.getMaven().getMojoParameterValue(mavenProject, parameter, asType, mojoExecution.getPlugin(),
execution, mojoExecution.getGoal(), null);
}, null);
return mavenFacade.getMojoParameterValue(parameter, asType, mojoExecution.getPlugin(), execution,
mojoExecution.getGoal(), null);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@
import org.codehaus.plexus.util.xml.Xpp3Dom;

import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.project.MavenProject;

import org.sonatype.plexus.build.incremental.BuildContext;

import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.IMaven;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant;

Expand All @@ -54,7 +51,6 @@ public MavenCompilerBuildParticipant(MojoExecution execution) {

@Override
public Set<IProject> build(int kind, IProgressMonitor monitor) throws Exception {
IMaven maven = MavenPlugin.getMaven();
BuildContext buildContext = getBuildContext();

MojoExecution mojoExecution = getMojoExecution();
Expand All @@ -63,12 +59,11 @@ public Set<IProject> build(int kind, IProgressMonitor monitor) throws Exception

//TODO check delta / scan source for *.java
IMavenProjectFacade mavenProjectFacade = getMavenProjectFacade();
MavenProject project = mavenProjectFacade.getMavenProject();
String compilerArgument = maven.getMojoParameterValue(project, mojoExecution, "compilerArgument", String.class,
null);
String compilerArgument = mavenProjectFacade.getMojoParameterValue(mojoExecution, "compilerArgument",
String.class, null);
boolean isAnnotationProcessingEnabled = (compilerArgument == null) || !compilerArgument.contains("-proc:none");
if(isAnnotationProcessingEnabled) {
String proc = maven.getMojoParameterValue(project, mojoExecution, PROC, String.class, null);
String proc = mavenProjectFacade.getMojoParameterValue(mojoExecution, PROC, String.class, null);
isAnnotationProcessingEnabled = !"none".equals(proc);
}
if(!isAnnotationProcessingEnabled) {
Expand Down Expand Up @@ -112,7 +107,7 @@ public Set<IProject> build(int kind, IProgressMonitor monitor) throws Exception
}

// tell m2e builder to refresh generated files
File generated = maven.getMojoParameterValue(project, getMojoExecution(),
File generated = mavenProjectFacade.getMojoParameterValue(getMojoExecution(),
MavenCompilerJdtAptDelegate.OUTPUT_DIRECTORY_PARAMETER, File.class, null);
if(generated != null) {
buildContext.refresh(generated);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.project.MavenProject;

import org.eclipse.m2e.apt.internal.AbstractAptConfiguratorDelegate;
import org.eclipse.m2e.apt.internal.AnnotationProcessorConfiguration;
Expand All @@ -45,8 +44,6 @@
import org.eclipse.m2e.apt.internal.processor.MavenProcessorJdtAptDelegate;
import org.eclipse.m2e.apt.internal.utils.PluginDependencyResolver;
import org.eclipse.m2e.apt.internal.utils.ProjectUtils;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.IMaven;
import org.eclipse.m2e.core.internal.markers.IMavenMarkerManager;
import org.eclipse.m2e.core.internal.markers.MavenProblemInfo;
import org.eclipse.m2e.core.internal.markers.SourceLocation;
Expand Down Expand Up @@ -118,46 +115,44 @@ public boolean isIgnored(IProgressMonitor monitor) {
@Override
protected AnnotationProcessorConfiguration getAnnotationProcessorConfiguration(IProgressMonitor monitor)
throws CoreException {
IMaven maven = MavenPlugin.getMaven();
markerManager.deleteMarkers(mavenFacade.getProject(), true, IMavenAptConstants.INVALID_ARGUMENT_MARKER_ID);
MavenProject mavenProject = mavenFacade.getMavenProject(monitor);
File generatedTestOutputDirectory = null;
for(MojoExecution mojoExecution : mavenFacade.getMojoExecutions(COMPILER_PLUGIN_GROUP_ID,
COMPILER_PLUGIN_ARTIFACT_ID, monitor, GOAL_TEST_COMPILE)) {
generatedTestOutputDirectory = maven.getMojoParameterValue(mavenProject, mojoExecution,
generatedTestOutputDirectory = mavenFacade.getMojoParameterValue(mojoExecution,
TEST_OUTPUT_DIRECTORY_PARAMETER, File.class, monitor);
}
for(MojoExecution mojoExecution : mavenFacade.getMojoExecutions(COMPILER_PLUGIN_GROUP_ID,
COMPILER_PLUGIN_ARTIFACT_ID, monitor, GOAL_COMPILE)) {
File generatedOutputDirectory = maven.getMojoParameterValue(mavenProject, mojoExecution,
File generatedOutputDirectory = mavenFacade.getMojoParameterValue(mojoExecution,
OUTPUT_DIRECTORY_PARAMETER, File.class, monitor);

Map<String, String> options = new HashMap<>();

@SuppressWarnings("unchecked")
Map<String, String> compilerArguments = maven.getMojoParameterValue(mavenProject, mojoExecution,
Map<String, String> compilerArguments = mavenFacade.getMojoParameterValue(mojoExecution,
"compilerArguments", Map.class, monitor);
options.putAll(extractProcessorOptions(compilerArguments));

// the single compiler argument takes precedence in maven-compiler-plugin
String compilerArgument = maven.getMojoParameterValue(mavenProject, mojoExecution, "compilerArgument",
String compilerArgument = mavenFacade.getMojoParameterValue(mojoExecution, "compilerArgument",
String.class, monitor);
options.putAll(parseProcessorOptions(compilerArgument));

@SuppressWarnings("unchecked")
List<String> compilerArgs = maven.getMojoParameterValue(mavenProject, mojoExecution, "compilerArgs", List.class,
List<String> compilerArgs = mavenFacade.getMojoParameterValue(mojoExecution, "compilerArgs", List.class,
monitor);
options.putAll(ProjectUtils.parseProcessorOptions(compilerArgs));

sanitizeOptionNames(options.keySet(), mojoExecution);

boolean isAnnotationProcessingEnabled = (compilerArgument == null) || !compilerArgument.contains("-proc:none");
if(isAnnotationProcessingEnabled) {
String proc = maven.getMojoParameterValue(mavenProject, mojoExecution, "proc", String.class, monitor);
String proc = mavenFacade.getMojoParameterValue(mojoExecution, "proc", String.class, monitor);
isAnnotationProcessingEnabled = !"none".equals(proc);
}

Dependency[] annotationProcessorPaths = maven.getMojoParameterValue(mavenProject, mojoExecution,
Dependency[] annotationProcessorPaths = mavenFacade.getMojoParameterValue(mojoExecution,
"annotationProcessorPaths", Dependency[].class, monitor);

boolean hasAnnotationProcessorPaths = annotationProcessorPaths.length > 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@
import org.codehaus.plexus.util.Scanner;

import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.project.MavenProject;

import org.sonatype.plexus.build.incremental.BuildContext;

import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.IMaven;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant;

Expand All @@ -58,11 +55,10 @@ public Set<IProject> build(int kind, IProgressMonitor monitor) throws Exception

//Modifying the pom triggers a build, otherwise, check for java source modifications
IMavenProjectFacade mavenFacade = getMavenProjectFacade();
MavenProject mavenProject = mavenFacade.getMavenProject();
if(!buildContext.hasDelta(mavenFacade.getPomFile())) {

// check if any of the java files changed
File source = getFileParameter(MavenProcessorJdtAptDelegate.SOURCE_DIRECTORY_PARAMETER, mavenProject);
File source = getFileParameter(MavenProcessorJdtAptDelegate.SOURCE_DIRECTORY_PARAMETER, mavenFacade);
Scanner ds = buildContext.newScanner(source); // delta or full scanner
ds.scan();
String[] includedFiles = ds.getIncludedFiles();
Expand All @@ -77,9 +73,9 @@ public Set<IProject> build(int kind, IProgressMonitor monitor) throws Exception
Set<IProject> result = super.build(kind, monitor);

// tell m2e builder to refresh generated files
File generated = getFileParameter(MavenProcessorJdtAptDelegate.OUTPUT_DIRECTORY_PARAMETER, mavenProject);
File generated = getFileParameter(MavenProcessorJdtAptDelegate.OUTPUT_DIRECTORY_PARAMETER, mavenFacade);
if(generated == null) {
generated = getFileParameter(MavenProcessorJdtAptDelegate.DEFAULT_OUTPUT_DIRECTORY_PARAMETER, mavenProject);
generated = getFileParameter(MavenProcessorJdtAptDelegate.DEFAULT_OUTPUT_DIRECTORY_PARAMETER, mavenFacade);
}
if(generated != null) {
buildContext.refresh(generated);
Expand All @@ -88,8 +84,7 @@ public Set<IProject> build(int kind, IProgressMonitor monitor) throws Exception
return result;
}

private File getFileParameter(String propertyId, MavenProject mavenProject) throws CoreException {
IMaven maven = MavenPlugin.getMaven();
return maven.getMojoParameterValue(mavenProject, getMojoExecution(), propertyId, File.class, null);
private File getFileParameter(String propertyId, IMavenProjectFacade mavenFacade) throws CoreException {
return mavenFacade.getMojoParameterValue(getMojoExecution(), propertyId, File.class, null);
}
}
2 changes: 1 addition & 1 deletion org.eclipse.m2e.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.m2e.core;singleton:=true
Bundle-Version: 2.7.900.qualifier
Bundle-Version: 2.8.0.qualifier
Bundle-Activator: org.eclipse.m2e.core.internal.MavenPluginActivator
Bundle-Vendor: %Bundle-Vendor
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,21 @@ MojoExecution setupMojoExecution(MavenProject project, MojoExecution execution,
* @return the parameter value or {@code null} if the parameter with the given name was not found
* @throws CoreException
* @since 1.4
* @deprecated use
* {@link IMavenProjectFacade#getMojoParameterValue(MojoExecution, String, Class, IProgressMonitor)}
* instead to avoid a direct dependency on {@link MavenProject}
*/
@Deprecated
<T> T getMojoParameterValue(MavenProject project, MojoExecution mojoExecution, String parameter,
Class<T> asType, IProgressMonitor monitor) throws CoreException;

/**
* @since 1.4
* @deprecated use
* {@link IMavenProjectFacade#getMojoParameterValue(String, Class, Plugin, ConfigurationContainer, String, IProgressMonitor)}
* instead to avoid a direct dependency on {@link MavenProject}
*/
@Deprecated
<T> T getMojoParameterValue(MavenProject project, String parameter, Class<T> type, Plugin plugin,
ConfigurationContainer configuration, String goal, IProgressMonitor monitor) throws CoreException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import org.apache.maven.lifecycle.DefaultLifecycles;
import org.apache.maven.lifecycle.MavenExecutionPlan;
import org.apache.maven.lifecycle.internal.LifecycleExecutionPlanCalculator;
import org.apache.maven.model.ConfigurationContainer;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.project.MavenProject;

Expand Down Expand Up @@ -584,6 +586,21 @@
return result;
}

@Override
@SuppressWarnings("deprecation")
public <T> T getMojoParameterValue(MojoExecution mojoExecution, String parameter, Class<T> asType,
IProgressMonitor monitor) throws CoreException {
return manager.maven.getMojoParameterValue(getMavenProject(monitor), mojoExecution, parameter, asType, monitor);
}

@Override
@SuppressWarnings("deprecation")
public <T> T getMojoParameterValue(String parameter, Class<T> type, Plugin plugin,
ConfigurationContainer configuration, String goal, IProgressMonitor monitor) throws CoreException {
return manager.maven.getMojoParameterValue(getMavenProject(monitor), parameter, type, plugin, configuration, goal,
monitor);
}

/**
* Returns cached list of MojoExecutions bound to project's clean, default and site lifecycles. Returned
* MojoExecutions are not fully setup and {@link IMaven#setupMojoExecution(MavenSession, MavenProject, MojoExecution)}
Expand Down Expand Up @@ -647,7 +664,7 @@
return manager.getContainerManager().getComponentLookup(getConfiguration().getMultiModuleProjectDirectory());
}

private static final class MavenProjectConfiguration implements IProjectConfiguration, Serializable {

Check warning on line 667 in org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MavenProjectFacade.java

View check run for this annotation

Jenkins - M2E / Compiler

Potential Programming Problem

NORMAL: The serializable class MavenProjectConfiguration does not declare a static final serialVersionUID field of type long

private final File multiModuleProjectDirectory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.eclipse.core.runtime.IProgressMonitor;

import org.apache.maven.lifecycle.MavenExecutionPlan;
import org.apache.maven.model.ConfigurationContainer;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.project.MavenProject;

Expand Down Expand Up @@ -174,6 +176,40 @@ MojoExecution getMojoExecution(MojoExecutionKey mojoExecutionKey, IProgressMonit
List<MojoExecution> getMojoExecutions(String groupId, String artifactId, IProgressMonitor monitor,
String... goals) throws CoreException;

/**
* Resolves a configuration parameter from the given {@code mojoExecution}. It coerces from String to the given type
* and considers expressions and default values.
*
* @param <T>
* @param mojoExecution the mojo execution from which to retrieve the configuration value
* @param parameter the name of the parameter (may be nested with separating {@code .})
* @param asType the type to coerce to
* @param monitor the progress monitor
* @return the parameter value or {@code null} if the parameter with the given name was not found
* @throws CoreException
* @since 2.8
*/
<T> T getMojoParameterValue(MojoExecution mojoExecution, String parameter, Class<T> asType,
IProgressMonitor monitor) throws CoreException;

/**
* Resolves a configuration parameter for the given {@code plugin}/{@code goal} combination. It coerces from String to
* the given type and considers expressions and default values.
*
* @param <T>
* @param parameter the name of the parameter (may be nested with separating {@code .})
* @param type the type to coerce to
* @param plugin the plugin declaring the parameter
* @param configuration the configuration to look up the parameter value in
* @param goal the goal of the plugin execution
* @param monitor the progress monitor
* @return the parameter value or {@code null} if the parameter with the given name was not found
* @throws CoreException
* @since 2.8
*/
<T> T getMojoParameterValue(String parameter, Class<T> type, Plugin plugin, ConfigurationContainer configuration,
String goal, IProgressMonitor monitor) throws CoreException;

// lifecycle mapping

String getLifecycleMappingId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,29 @@

/**
* @since 1.4
* @deprecated use {@link #getParameterValue(IMavenProjectFacade, String, Class, MojoExecution, IProgressMonitor)}
* instead to avoid a direct dependency on {@link MavenProject}
*/
@Deprecated
protected <T> T getParameterValue(MavenProject project, String parameter, Class<T> asType,
MojoExecution mojoExecution, IProgressMonitor monitor) throws CoreException {
PluginExecution execution = new PluginExecution();
execution.setConfiguration(mojoExecution.getConfiguration());
return maven.getMojoParameterValue(project, parameter, asType, mojoExecution.getPlugin(), execution,

Check warning on line 189 in org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractProjectConfigurator.java

View check run for this annotation

Jenkins - M2E / Compiler

Deprecation

NORMAL: The method getMojoParameterValue(MavenProject, String, Class , Plugin, ConfigurationContainer, String, IProgressMonitor) from the type IMaven is deprecated
mojoExecution.getGoal(), monitor);
}

/**
* @since 2.8
*/
protected <T> T getParameterValue(IMavenProjectFacade projectFacade, String parameter, Class<T> asType,
MojoExecution mojoExecution, IProgressMonitor monitor) throws CoreException {
PluginExecution execution = new PluginExecution();
execution.setConfiguration(mojoExecution.getConfiguration());
return projectFacade.getMojoParameterValue(parameter, asType, mojoExecution.getPlugin(), execution,
mojoExecution.getGoal(), monitor);
}

protected void assertHasNature(IProject project, String natureId) throws CoreException {
if(project.getNature(natureId) == null) {
throw new CoreException(Status.error(Messages.AbstractProjectConfigurator_error_missing_nature + ' ' + natureId));
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.m2e.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.m2e.feature"
label="%featureName"
version="2.10.300.qualifier"
version="2.11.0.qualifier"
provider-name="%providerName"
plugin="org.eclipse.m2e.core"
license-feature="org.eclipse.license"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ protected IPath getFullPath(IMavenProjectFacade facade, File file) {

protected File[] getSourceFolders(ProjectConfigurationRequest request, MojoExecution mojoExecution,
IProgressMonitor monitor) throws CoreException {
return new File[] {
getParameterValue(request.mavenProject(), getOutputFolderParameterName(), File.class, mojoExecution, monitor)};
return new File[] {getParameterValue(request.mavenProjectFacade(), getOutputFolderParameterName(), File.class,
mojoExecution, monitor)};
}

protected String getOutputFolderParameterName() {
Expand Down
Loading
Loading