desruisseaux commented on code in PR #2085:
URL: https://github.com/apache/maven/pull/2085#discussion_r1944434317


##########
impl/maven-core/src/main/java/org/apache/maven/project/MavenProject.java:
##########
@@ -770,23 +738,69 @@ public Build getBuild() {
      */
     @Deprecated(since = "4.0.0")
     public List<Resource> getResources() {
-        return getBuild().getResources();
+        return new AbstractList<>() {
+            @Override
+            public Resource get(int index) {
+                return toResource(getEnabledSourceRoots(ProjectScope.MAIN, 
Language.RESOURCES)
+                        .toList()
+                        .get(index));
+            }
+
+            @Override
+            public int size() {
+                return (int) getEnabledSourceRoots(ProjectScope.MAIN, 
Language.RESOURCES)
+                        .count();
+            }
+
+            @Override
+            public boolean add(Resource resource) {
+                addResource(resource);
+                return true;
+            }
+        };
     }
 
     /**
      * @deprecated Replaced by {@code getEnabledSourceRoots(ProjectScope.TEST, 
Language.RESOURCES)}.
      */
     @Deprecated(since = "4.0.0")
     public List<Resource> getTestResources() {
-        return getBuild().getTestResources();
+        return new AbstractList<>() {
+            @Override
+            public Resource get(int index) {
+                return toResource(getEnabledSourceRoots(ProjectScope.TEST, 
Language.RESOURCES)
+                        .toList()
+                        .get(index));
+            }
+
+            @Override
+            public int size() {
+                return (int) getEnabledSourceRoots(ProjectScope.TEST, 
Language.RESOURCES)

Review Comment:
   It would be safer to replace the `(int)` casts by  `Math.toIntExact(long)`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to