From 2c718eb96c5307093b0bb81ea5d014138580d26e Mon Sep 17 00:00:00 2001 From: krrish175-byte Date: Sat, 10 Jan 2026 10:06:01 +0530 Subject: [PATCH 1/4] fix: use List/Nil instead of Option for resource flatMap --- .../bloop/integrations/maven/MojoImplementation.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/bloop/integrations/maven/MojoImplementation.scala b/src/main/scala/bloop/integrations/maven/MojoImplementation.scala index 6126424..cfb481a 100644 --- a/src/main/scala/bloop/integrations/maven/MojoImplementation.scala +++ b/src/main/scala/bloop/integrations/maven/MojoImplementation.scala @@ -313,17 +313,17 @@ object MojoImplementation { val dir = Paths.get(a.getDirectory()) if (Files.exists(dir)) { if (a.getIncludes().isEmpty() && a.getExcludes().isEmpty()) { - Some(dir) + List(dir) } else { val scanner = new DirectoryScanner() scanner.setBasedir(a.getDirectory()) scanner.setIncludes(a.getIncludes().toArray(new Array[String](0))) scanner.setExcludes(a.getExcludes().toArray(new Array[String](0))) scanner.scan() - scanner.getIncludedFiles().map(f => dir.resolve(f)) + scanner.getIncludedFiles().toList.map(f => dir.resolve(f)) } - } else None - case _ => None + } else Nil + case _ => Nil }) val project = Config.Project(name, baseDirectory, Some(root.toPath), sourceDirs, None, None, fullDependencies, classpath, out, classesDir, resources, `scala`, java, sbt, test, platform, resolution, Some(tags), None) Config.File(Config.File.LatestVersion, project) From 7ed2e3a1697739b160bfec23c4644d6ba0cd339f Mon Sep 17 00:00:00 2001 From: krrish175-byte Date: Sat, 10 Jan 2026 17:16:56 +0530 Subject: [PATCH 2/4] Add regression test for issue #85 fix --- .../maven/MavenConfigGenerationTest.scala | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/test/scala/bloop/integrations/maven/MavenConfigGenerationTest.scala b/src/test/scala/bloop/integrations/maven/MavenConfigGenerationTest.scala index 1a198b0..590366d 100644 --- a/src/test/scala/bloop/integrations/maven/MavenConfigGenerationTest.scala +++ b/src/test/scala/bloop/integrations/maven/MavenConfigGenerationTest.scala @@ -401,4 +401,25 @@ class MavenConfigGenerationTest extends BaseConfigSuite { } } + @Test + def defaultResources() = { + check( + "basic_scala/pom.xml", + extraContent = Map( + "basic_scala/src/main/resources/hello.txt" -> "hello" + ) + ) { (configFile, projectName, subprojects) => + assert(subprojects.isEmpty) + val resources = configFile.project.resources.getOrElse(Nil) + // When no includes/excludes are specified, the whole directory should be included + val resourceDir = configFile.project.directory.resolve("src/main/resources").toAbsolutePath + val hasResourceDir = resources.exists(_.toAbsolutePath == resourceDir) + assert(hasResourceDir, s"Resource directory $resourceDir SHOULD be in resources") + + // Individual files should NOT be listed + val hasFile = resources.exists(_.toString.endsWith("hello.txt")) + assert(!hasFile, "Individual files inside resource dir should NOT be in resources list") + } + } + } From ec79534e42dffc1343b7f336f2cd46f7d17c1e0e Mon Sep 17 00:00:00 2001 From: krrish175-byte Date: Mon, 12 Jan 2026 21:29:28 +0530 Subject: [PATCH 3/4] test: use dedicated project for default resources test --- src/test/resources/default_resources/pom.xml | 19 +++++++++++++++++++ .../maven/MavenConfigGenerationTest.scala | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 src/test/resources/default_resources/pom.xml diff --git a/src/test/resources/default_resources/pom.xml b/src/test/resources/default_resources/pom.xml new file mode 100644 index 0000000..7090c13 --- /dev/null +++ b/src/test/resources/default_resources/pom.xml @@ -0,0 +1,19 @@ + + 4.0.0 + + bloop.test + default_resources + 1.0-SNAPSHOT + jar + + default-resources-test + + + + + ${project.basedir}/src/main/resources + + + + diff --git a/src/test/scala/bloop/integrations/maven/MavenConfigGenerationTest.scala b/src/test/scala/bloop/integrations/maven/MavenConfigGenerationTest.scala index 590366d..c34ec09 100644 --- a/src/test/scala/bloop/integrations/maven/MavenConfigGenerationTest.scala +++ b/src/test/scala/bloop/integrations/maven/MavenConfigGenerationTest.scala @@ -404,9 +404,9 @@ class MavenConfigGenerationTest extends BaseConfigSuite { @Test def defaultResources() = { check( - "basic_scala/pom.xml", + "default_resources/pom.xml", extraContent = Map( - "basic_scala/src/main/resources/hello.txt" -> "hello" + "default_resources/src/main/resources/hello.txt" -> "hello" ) ) { (configFile, projectName, subprojects) => assert(subprojects.isEmpty) From 1f6056787e46ba70bcac1ccecab4b5e0773dd06b Mon Sep 17 00:00:00 2001 From: krrish175-byte Date: Wed, 14 Jan 2026 12:40:13 +0530 Subject: [PATCH 4/4] Add test case for in maven resources --- src/test/resources/with_includes/pom.xml | 22 ++++++++++++++++ .../maven/MavenConfigGenerationTest.scala | 25 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/test/resources/with_includes/pom.xml diff --git a/src/test/resources/with_includes/pom.xml b/src/test/resources/with_includes/pom.xml new file mode 100644 index 0000000..df023d8 --- /dev/null +++ b/src/test/resources/with_includes/pom.xml @@ -0,0 +1,22 @@ + + 4.0.0 + + bloop.test + with_includes + 1.0-SNAPSHOT + jar + + with-includes-test + + + + + ${project.basedir}/src/main/resources + + included.txt + + + + + diff --git a/src/test/scala/bloop/integrations/maven/MavenConfigGenerationTest.scala b/src/test/scala/bloop/integrations/maven/MavenConfigGenerationTest.scala index c34ec09..3a43b7a 100644 --- a/src/test/scala/bloop/integrations/maven/MavenConfigGenerationTest.scala +++ b/src/test/scala/bloop/integrations/maven/MavenConfigGenerationTest.scala @@ -379,6 +379,31 @@ class MavenConfigGenerationTest extends BaseConfigSuite { + @Test + def withIncludes() = { + check( + "with_includes/pom.xml", + extraContent = Map( + "with_includes/src/main/resources/included.txt" -> "This file should be included.", + "with_includes/src/main/resources/excluded.txt" -> "This file should be excluded." + ) + ) { (configFile, projectName, subprojects) => + assert(subprojects.isEmpty) + val resources = configFile.project.resources.getOrElse(Nil) + + val included = resources.find(_.toString.endsWith("included.txt")) + val excluded = resources.find(_.toString.endsWith("excluded.txt")) + + assert(included.isDefined, "included.txt should be in resources") + assert(excluded.isEmpty, "excluded.txt should NOT be in resources") + + // Ensure the directory itself is not added when we have explicit includes + val resourceDir = configFile.project.directory.resolve("src/main/resources").toAbsolutePath + val hasResourceDir = resources.exists(_.toAbsolutePath == resourceDir) + assert(!hasResourceDir, s"Resource directory $resourceDir should NOT be in resources when includes are specified") + } + } + @Test def issue85() = { check(