From 96dc114889e07891b8f89067ca9acb30e0c965f9 Mon Sep 17 00:00:00 2001 From: qxo Date: Sat, 17 Feb 2024 15:14:51 +0000 Subject: [PATCH 1/3] fix: resource excluding change ** to **/*.java --- .../m2e/jdt/internal/AbstractJavaProjectConfigurator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6e6cfa4edf..46fa54450f 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 @@ -582,7 +582,7 @@ private void addResourceFolder(IClasspathDescriptor classpath, IPath resourceFol boolean addTestFlag) { log.info("Adding resource folder " + resourceFolder); IClasspathEntryDescriptor descriptor = classpath.addSourceEntry(resourceFolder, outputPath, DEFAULT_INCLUSIONS, - new IPath[] {IPath.fromOSString("**")}, false /*optional*/); + new IPath[] {IPath.fromOSString("**/*.java")}, false /*optional*/); descriptor.setClasspathAttribute(IClasspathManager.TEST_ATTRIBUTE, addTestFlag ? "true" : null); descriptor.setClasspathAttribute(IClasspathAttribute.OPTIONAL, "true"); //$NON-NLS-1$ } From 04b6e6f4e990cc32044ca2a40eff4358dadecc92 Mon Sep 17 00:00:00 2001 From: qxo Date: Sat, 17 Feb 2024 15:15:02 +0000 Subject: [PATCH 2/3] feat: classpathentry should respect pom resource excludes/includes,: so we build project on eclipse without org.eclipse.m2e.core.maven2Builder --- .../AbstractJavaProjectConfigurator.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) 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 46fa54450f..0b6ef778ff 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 @@ -566,7 +566,7 @@ private void addResourceDirs(IClasspathDescriptor classpath, IProject project, M // skip adding resource folders that are included by other resource folders log.info("Skipping resource folder " + path + " since it's contained by another resource folder"); } else { - addResourceFolder(classpath, path, outputPath, addTestFlag); + addResourceFolder(classpath, path, outputPath, addTestFlag, resource); } // Set folder encoding (null = platform default) if(r.exists()) { @@ -579,14 +579,29 @@ private void addResourceDirs(IClasspathDescriptor classpath, IProject project, M } private void addResourceFolder(IClasspathDescriptor classpath, IPath resourceFolder, IPath outputPath, - boolean addTestFlag) { + boolean addTestFlag, Resource resource) { log.info("Adding resource folder " + resourceFolder); - IClasspathEntryDescriptor descriptor = classpath.addSourceEntry(resourceFolder, outputPath, DEFAULT_INCLUSIONS, - new IPath[] {IPath.fromOSString("**/*.java")}, false /*optional*/); + IClasspathEntryDescriptor descriptor = classpath.addSourceEntry(resourceFolder, outputPath, + toIPathList(resource.getIncludes(), null), + toIPathList(resource.getExcludes(), "**/*.java"), false /*optional*/); descriptor.setClasspathAttribute(IClasspathManager.TEST_ATTRIBUTE, addTestFlag ? "true" : null); descriptor.setClasspathAttribute(IClasspathAttribute.OPTIONAL, "true"); //$NON-NLS-1$ } + private IPath[] toIPathList(final List fileNames, final String defaultPattern) { + if (fileNames == null) { + return defaultPattern != null ? new IPath[] {IPath.fromOSString(defaultPattern)} : DEFAULT_INCLUSIONS; + } + final List retList = new ArrayList<>(); + for (final String files : fileNames) { + retList.add(IPath.fromOSString(files)); + } + if (defaultPattern != null) { + retList.add(IPath.fromOSString(defaultPattern)); + } + return retList.toArray(DEFAULT_INCLUSIONS); + } + private void configureOverlapWithSource(IClasspathDescriptor classpath, IClasspathEntryDescriptor enclosing, IPath resourceFolder) { // resources and sources folders overlap. make sure JDT only processes java sources. From 40a80f41279433092cf9fd11efc8fdd1f54172fd Mon Sep 17 00:00:00 2001 From: qxo Date: Sat, 17 Feb 2024 15:15:08 +0000 Subject: [PATCH 3/3] fix: resource excluding change ** to maven standard --- .../m2e/jdt/internal/AbstractJavaProjectConfigurator.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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 0b6ef778ff..18ea68ee7c 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 @@ -583,7 +583,7 @@ private void addResourceFolder(IClasspathDescriptor classpath, IPath resourceFol log.info("Adding resource folder " + resourceFolder); IClasspathEntryDescriptor descriptor = classpath.addSourceEntry(resourceFolder, outputPath, toIPathList(resource.getIncludes(), null), - toIPathList(resource.getExcludes(), "**/*.java"), false /*optional*/); + toIPathList(resource.getExcludes(), null), false /*optional*/); descriptor.setClasspathAttribute(IClasspathManager.TEST_ATTRIBUTE, addTestFlag ? "true" : null); descriptor.setClasspathAttribute(IClasspathAttribute.OPTIONAL, "true"); //$NON-NLS-1$ } @@ -596,9 +596,6 @@ private IPath[] toIPathList(final List fileNames, final String defaultPa for (final String files : fileNames) { retList.add(IPath.fromOSString(files)); } - if (defaultPattern != null) { - retList.add(IPath.fromOSString(defaultPattern)); - } return retList.toArray(DEFAULT_INCLUSIONS); }