diff --git a/m2e-core-tests b/m2e-core-tests index 056b30ee95..fb29bb56f0 160000 --- a/m2e-core-tests +++ b/m2e-core-tests @@ -1 +1 @@ -Subproject commit 056b30ee9530790ade82bb92251d3fa658ebb38a +Subproject commit fb29bb56f0109aa1775cb9be6d194272575e8578 diff --git a/org.eclipse.m2e.jdt.tests/projects/add-source-resource/parent/java/A.java b/org.eclipse.m2e.jdt.tests/projects/add-source-resource/parent/java/A.java new file mode 100644 index 0000000000..83b86122f3 --- /dev/null +++ b/org.eclipse.m2e.jdt.tests/projects/add-source-resource/parent/java/A.java @@ -0,0 +1,5 @@ +import java.io.Serializable; + +class A implements Serializable { + +} diff --git a/org.eclipse.m2e.jdt.tests/projects/add-source-resource/parent/resources/res.txt b/org.eclipse.m2e.jdt.tests/projects/add-source-resource/parent/resources/res.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/org.eclipse.m2e.jdt.tests/projects/add-source-resource/parent/test-resources/test.txt b/org.eclipse.m2e.jdt.tests/projects/add-source-resource/parent/test-resources/test.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/org.eclipse.m2e.jdt.tests/projects/add-source-resource/parent/test/ATest.java b/org.eclipse.m2e.jdt.tests/projects/add-source-resource/parent/test/ATest.java new file mode 100644 index 0000000000..396f5b59a4 --- /dev/null +++ b/org.eclipse.m2e.jdt.tests/projects/add-source-resource/parent/test/ATest.java @@ -0,0 +1,5 @@ +import java.io.Serializable; + +class ATest implements Serializable { + +} diff --git a/org.eclipse.m2e.jdt.tests/projects/add-source-resource/pom.xml b/org.eclipse.m2e.jdt.tests/projects/add-source-resource/pom.xml new file mode 100644 index 0000000000..b77a70ef1c --- /dev/null +++ b/org.eclipse.m2e.jdt.tests/projects/add-source-resource/pom.xml @@ -0,0 +1,13 @@ + + + 4.0.0 + foo.bar + add-source-resource + 0.0.1-SNAPSHOT + pom + + submoduleA + + diff --git a/org.eclipse.m2e.jdt.tests/projects/add-source-resource/submoduleA/pom.xml b/org.eclipse.m2e.jdt.tests/projects/add-source-resource/submoduleA/pom.xml new file mode 100644 index 0000000000..155a11dfa1 --- /dev/null +++ b/org.eclipse.m2e.jdt.tests/projects/add-source-resource/submoduleA/pom.xml @@ -0,0 +1,80 @@ + + + 4.0.0 + foo.bar + submoduleA + 0.0.1-SNAPSHOT + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.10.1 + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + java + generate-sources + + add-source + + + + ../parent/java + + + + + test + generate-sources + + add-test-source + + + + ../parent/test + + + + + resources + generate-resources + + add-resource + + + + + ../parent/resources + + + + + + test-resources + generate-resources + + add-test-resource + + + + + ../parent/test-resources + + + + + + + + + diff --git a/org.eclipse.m2e.jdt.tests/src/org/eclipse/m2e/jdt/tests/JavaConfigurationTest.java b/org.eclipse.m2e.jdt.tests/src/org/eclipse/m2e/jdt/tests/JavaConfigurationTest.java index e56ccb6798..80a7e4f5a1 100644 --- a/org.eclipse.m2e.jdt.tests/src/org/eclipse/m2e/jdt/tests/JavaConfigurationTest.java +++ b/org.eclipse.m2e.jdt.tests/src/org/eclipse/m2e/jdt/tests/JavaConfigurationTest.java @@ -35,6 +35,7 @@ import org.eclipse.jdt.core.JavaModelException; import org.eclipse.m2e.core.MavenPlugin; import org.eclipse.m2e.core.internal.preferences.MavenConfigurationImpl; +import org.eclipse.m2e.core.project.ResolverConfiguration; import org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase; import org.junit.Before; import org.junit.Test; @@ -132,6 +133,20 @@ public void testComplianceVsEnablePreviewSettings() throws CoreException, IOExce assertEquals(JavaCore.ENABLED, project.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, false)); assertEquals(JavaCore.IGNORE, project.getOption(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, false)); } + + @Test + public void testAddSourceResource() throws CoreException, IOException, InterruptedException { + File baseDir = new File(FileLocator + .toFileURL(JavaConfigurationTest.class.getResource("/projects/add-source-resource/submoduleA/pom.xml")) + .getFile()).getParentFile().getParentFile(); + waitForJobsToComplete(); + IProject project = importProjects(baseDir.getAbsolutePath(), new String[] { "submoduleA/pom.xml" }, + new ResolverConfiguration())[0]; + waitForJobsToComplete(); + IJavaProject javaProject = JavaCore.create(project); + assertEquals(8, Arrays.stream(javaProject.getRawClasspath()) + .filter(cp -> IClasspathEntry.CPE_SOURCE == cp.getEntryKind()).count()); + } // --- utility methods --- private static final Predicate TEST_SOURCES = cp -> cp.isTest() diff --git a/org.eclipse.m2e.jdt/META-INF/MANIFEST.MF b/org.eclipse.m2e.jdt/META-INF/MANIFEST.MF index d44e80dc90..f874d1c804 100644 --- a/org.eclipse.m2e.jdt/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.jdt/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.m2e.jdt;singleton:=true -Bundle-Version: 2.3.3.qualifier +Bundle-Version: 2.3.4.qualifier Bundle-Localization: plugin Export-Package: org.eclipse.m2e.jdt, org.eclipse.m2e.jdt.internal;x-friends:="org.eclipse.m2e.jdt.ui", diff --git a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java index 593febb513..2954e3afa3 100644 --- a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java +++ b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java @@ -14,6 +14,7 @@ package org.eclipse.m2e.jdt.internal; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -33,6 +34,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.SubMonitor; import org.eclipse.jdt.core.IAccessRule; import org.eclipse.jdt.core.IClasspathAttribute; @@ -134,6 +136,9 @@ public abstract class AbstractJavaProjectConfigurator extends AbstractProjectCon protected static final String DEFAULT_COMPILER_LEVEL = "1.5"; //$NON-NLS-1$ + private static final QualifiedName LINKED_RESOURCE_PROPERTY = new QualifiedName(MavenJdtPlugin.PLUGIN_ID, + "linkedSource"); + @Override public void configure(ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException { IProject project = request.mavenProjectFacade().getProject(); @@ -361,6 +366,9 @@ protected void addProjectSourceFolders(IClasspathDescriptor classpath, Map