Permalink
Browse files

395512 resolve missing plugin versions

otherwise DefaultPluginDescriptorCache$CacheKey for plugin is not
fully initialized and will throw NPE on version field access.

Bug: 395512
Change-Id: Ibf9caccadcee52b18ffb0033e38ddf212f5114b7
  • Loading branch information...
1 parent 08631a0 commit 1a17dddb22d164a716637476ab82f63449e64e19 @jsievers jsievers committed Jan 8, 2013
@@ -12,6 +12,7 @@
import org.apache.maven.MavenExecutionException;
import org.apache.maven.execution.MavenSession;
+import org.apache.maven.lifecycle.internal.LifecyclePluginResolver;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.BuildPluginManager;
import org.apache.maven.plugin.InvalidPluginDescriptorException;
@@ -21,6 +22,7 @@
import org.apache.maven.plugin.PluginManagerException;
import org.apache.maven.plugin.PluginResolutionException;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.plugin.version.PluginVersionResolutionException;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.component.annotations.Component;
@@ -72,6 +74,9 @@
@Requirement
private PluginDescriptorCache pluginDescriptorCache;
+ @Requirement
+ private LifecyclePluginResolver lifecyclePluginResolver;
+
public void execute(MavenSession session, MavenProject project, Runnable runnable, PluginFilter filter)
throws MavenExecutionException {
for (Plugin plugin : project.getBuildPlugins()) {
@@ -83,6 +88,7 @@ public void execute(MavenSession session, MavenProject project, Runnable runnabl
continue;
}
try {
+ lifecyclePluginResolver.resolveMissingPluginVersions(project, session);
PluginDescriptor pluginDescriptor = pluginManager.getPluginDescriptor(plugin,
project.getRemotePluginRepositories(), session.getRepositorySession());
@@ -121,6 +127,8 @@ public void execute(MavenSession session, MavenProject project, Runnable runnabl
throw newMavenExecutionException(e);
} catch (PluginResolutionException e) {
throw newMavenExecutionException(e);
+ } catch (PluginVersionResolutionException e) {
+ throw newMavenExecutionException(e);
} catch (PluginDescriptorParsingException e) {
throw newMavenExecutionException(e);
} catch (InvalidPluginDescriptorException e) {
@@ -0,0 +1,4 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: test
+Bundle-Version: 1.0.0.qualifier
@@ -0,0 +1,2 @@
+bin.includes = META-INF/,\
+ .
@@ -0,0 +1,25 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>tychoits.missing.plugin.version</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-maven-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <!-- missing version element was causing NPE -->
+ </plugin>
+ </plugins>
+ </build>
+</project>
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2013 SAP AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tycho.test;
+
+import org.apache.maven.it.Verifier;
+import org.junit.Test;
+
+public class MissingPluginVersionsTest extends AbstractTychoIntegrationTest {
+
+ @Test
+ public void testMissingPluginVersion() throws Exception {
+ Verifier verifier = getVerifier("missingPluginVersions", false);
+ verifier.executeGoal("compile");
+ verifier.verifyErrorFreeLog();
+ }
+}

0 comments on commit 1a17ddd

Please sign in to comment.