use of org.apache.maven.plugin.InvalidPluginDescriptorException in project tycho by eclipse.
the class PluginRealmHelper method execute.
public void execute(MavenSession session, MavenProject project, Runnable runnable, PluginFilter filter) throws MavenExecutionException {
for (Plugin plugin : project.getBuildPlugins()) {
if (plugin.isExtensions()) {
// https://cwiki.apache.org/MAVEN/maven-3x-class-loading.html
continue;
}
try {
lifecyclePluginResolver.resolveMissingPluginVersions(project, session);
PluginDescriptor pluginDescriptor;
try {
pluginDescriptor = compatibilityHelper.getPluginDescriptor(plugin, project, session);
} catch (PluginResolutionException e) {
// if the plugin really does not exist, the Maven build will fail later on anyway -> ignore for now (cf. bug #432957)
logger.debug("PluginResolutionException while looking for components from " + plugin, e);
continue;
}
if (pluginDescriptor != null) {
if (pluginDescriptor.getArtifactMap().isEmpty() && pluginDescriptor.getDependencies().isEmpty()) {
// force plugin descriptor reload to workaround http://jira.codehaus.org/browse/MNG-5212
// this branch won't be executed on 3.0.5+, where MNG-5212 is fixed already
PluginDescriptorCache.Key descriptorCacheKey = compatibilityHelper.createKey(plugin, project, session);
pluginDescriptorCache.put(descriptorCacheKey, null);
pluginDescriptor = compatibilityHelper.getPluginDescriptor(plugin, project, session);
}
if (filter == null || filter.accept(pluginDescriptor)) {
ClassRealm pluginRealm;
MavenProject oldCurrentProject = session.getCurrentProject();
session.setCurrentProject(project);
try {
pluginRealm = buildPluginManager.getPluginRealm(session, pluginDescriptor);
} finally {
session.setCurrentProject(oldCurrentProject);
}
if (pluginRealm != null) {
ClassLoader origTCCL = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(pluginRealm);
runnable.run();
} finally {
Thread.currentThread().setContextClassLoader(origTCCL);
}
}
}
}
} catch (PluginManagerException e) {
throw newMavenExecutionException(e);
} catch (PluginResolutionException e) {
throw newMavenExecutionException(e);
} catch (PluginVersionResolutionException e) {
throw newMavenExecutionException(e);
} catch (PluginDescriptorParsingException e) {
throw newMavenExecutionException(e);
} catch (InvalidPluginDescriptorException e) {
throw newMavenExecutionException(e);
}
}
}
Aggregations