Skip to content

Commit ca08523

Browse files
HannesWelllaeubi
authored andcommitted
Propagate Mojo-lookup errors and create test-case for #1150
1 parent 7fca6de commit ca08523

File tree

5 files changed

+41
-1
lines changed

5 files changed

+41
-1
lines changed

org.eclipse.m2e.core.tests/resources/projects/resourcesWithMVNFolder/.mvn/.gitkeep

Whitespace-only changes.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>foo</groupId>
6+
<artifactId>bar</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
<properties>
9+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10+
</properties>
11+
<build>
12+
<pluginManagement>
13+
<plugins>
14+
<plugin>
15+
<groupId>org.apache.maven.plugins</groupId>
16+
<artifactId>maven-compiler-plugin</artifactId>
17+
<version>3.10.1</version>
18+
<configuration>
19+
<release>17</release>
20+
</configuration>
21+
</plugin>
22+
</plugins>
23+
</pluginManagement>
24+
</build>
25+
</project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
foo-bar-content

org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/ExtensionsTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
import java.util.Collection;
1818

1919
import org.apache.maven.AbstractMavenLifecycleParticipant;
20+
import org.eclipse.core.resources.IFile;
2021
import org.eclipse.core.resources.IProject;
22+
import org.eclipse.core.resources.IncrementalProjectBuilder;
2123
import org.eclipse.core.runtime.Adapters;
2224
import org.eclipse.core.runtime.CoreException;
2325
import org.eclipse.m2e.core.embedder.IComponentLookup;
@@ -82,6 +84,16 @@ public void testReloadExtensionAfterDeletion() throws Exception {
8284
assertEquals("my.bundle", project1.getName());
8385
}
8486

87+
@Test
88+
public void testCopyResourcesWithMVNFolder() throws Exception {
89+
IProject project = importProject("resources/projects/resourcesWithMVNFolder/pom.xml");
90+
project.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
91+
WorkspaceHelpers.assertNoErrors(project);
92+
IFile file = project.getFile("target/classes/file.txt");
93+
assertTrue(file.exists());
94+
assertEquals("foo-bar-content", new String(file.getContents().readAllBytes()));
95+
}
96+
8597
private IProject importPomlessProject(String rootProject, String... poms) throws IOException, CoreException {
8698
IProject[] projects = importProjects("resources/projects/" + rootProject + "/", poms,
8799
new ResolverConfiguration(), false);

org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenExecutionContext.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ public MavenExecutionResult execute(MavenExecutionRequest request) {
317317
}
318318
}
319319

320-
private static void executeMojo(MavenSession session, MojoExecution execution, IComponentLookup lookup) {
320+
private static void executeMojo(MavenSession session, MojoExecution execution, IComponentLookup lookup)
321+
throws CoreException {
321322
Map<MavenProject, Set<Artifact>> artifacts = new HashMap<>();
322323
Map<MavenProject, MavenProjectMutableState> snapshots = new HashMap<>();
323324
for(MavenProject project : session.getProjects()) {
@@ -331,6 +332,7 @@ private static void executeMojo(MavenSession session, MojoExecution execution, I
331332
lookup.lookup(BuildPluginManager.class).executeMojo(session, execution);
332333
} catch(Exception ex) {
333334
session.getResult().addException(ex);
335+
throw new CoreException(Status.error("Failed to execute mojo", ex));
334336
} finally {
335337
for(MavenProject project : session.getProjects()) {
336338
project.setArtifactFilter(null);

0 commit comments

Comments
 (0)