Skip to content

Commit 1c8af4d

Browse files
Fix compiler warnings
1 parent 1daf27d commit 1c8af4d

File tree

5 files changed

+21
-16
lines changed

5 files changed

+21
-16
lines changed

src/main/java/org/javamodularity/moduleplugin/ModuleSystemPlugin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public void apply(Project project) {
2727
new ModuleName().findModuleName(project).ifPresent(moduleName -> configureModularity(project, moduleName));
2828
}
2929

30+
@SuppressWarnings("deprecation")
3031
private void configureModularity(Project project, String moduleName) {
3132
ExtensionContainer extensions = project.getExtensions();
3233
extensions.add("moduleName", moduleName);

src/main/java/org/javamodularity/moduleplugin/extensions/PatchModuleContainer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public static void configure(Project project) {
7373
project.afterEvaluate(container::configureAfterEvaluate);
7474
}
7575

76+
@SuppressWarnings("deprecation")
7677
private void configureAfterEvaluate(Project project) {
7778
PatchModuleExtension patchModuleExtension = new JavaProjectHelper(project).extension(PatchModuleExtension.class);
7879
patchModuleExtension.getConfig().forEach( config -> {

src/main/java/org/javamodularity/moduleplugin/extensions/PatchModuleExtension.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ public void setConfig(List<String> config) {
2727
}
2828

2929
/** @deprecated As of 1.7.0, this method is no longer used and can be removed */
30+
@SuppressWarnings("removal")
3031
@Deprecated(since = "1.7.0", forRemoval = true)
3132
public PatchModuleResolver resolvePatched(FileCollection classpath) {
3233
return resolvePatched(jarName -> classpath.filter(jar -> jar.getName().endsWith(jarName)).getAsPath());
3334
}
3435

3536
/** @deprecated As of 1.7.0, this method is no longer used and can be removed */
37+
@SuppressWarnings("removal")
3638
@Deprecated(since = "1.7.0", forRemoval = true)
3739
public PatchModuleResolver resolvePatched(UnaryOperator<String> jarNameResolver) {
3840
return new PatchModuleResolver(this, jarNameResolver);

src/main/java/org/javamodularity/moduleplugin/tasks/ClasspathFile.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.Map;
55
import java.util.Optional;
66
import java.util.concurrent.ConcurrentSkipListMap;
7+
import java.util.stream.Stream;
78
import org.gradle.api.Task;
89
import org.gradle.api.logging.Logger;
910
import org.gradle.api.logging.Logging;
@@ -132,8 +133,7 @@ public void configure(final Task task) {
132133
// </attributes>
133134
// </classpathentry>
134135

135-
rootNode.children().stream() // loop over all children
136-
.filter(i -> i instanceof Node) // better safe than sorry
136+
children(rootNode) // loop over all children
137137
.filter(i -> NAME_ITEM.equals(((Node)i).name())) // with name "classpathentry"
138138
.filter(i -> isKindOf((Node)i, "lib")) // kind of "lib"
139139
.filter(i -> getGradleScope((Node)i).contains("main")) // appropriate gradle scope
@@ -169,8 +169,7 @@ public void configure(final Task task) {
169169
// </attributes>
170170
// </classpathentry>
171171

172-
rootNode.children().stream() // loop over all children
173-
.filter(i -> i instanceof Node) // better safe than sorry
172+
children(rootNode) // loop over all children
174173
.filter(i -> NAME_ITEM.equals(((Node)i).name())) // with name "classpathentry"
175174
.filter(i -> "test".equals(getGradleScope((Node)i))) // appropriate gradle scope
176175
.filter(i -> hasNoAttributeTest((Node)i)) // without "test" information
@@ -193,8 +192,7 @@ public void configure(final Task task) {
193192
* XML-content to be improved
194193
*/
195194
/* package */ void putJreOnModulePath(final Node rootNode) {
196-
rootNode.children().stream() // loop over all children
197-
.filter(i -> i instanceof Node) // better safe than sorry
195+
children(rootNode) // loop over all children
198196
.filter(i -> NAME_ITEM.equals(((Node)i).name())) // with name "classpathentry"
199197
.filter(i -> isJre((Node)i)) // indicating JRE
200198
.filter(i -> hasNoAttributeModule((Node)i)) // without "module" information
@@ -225,8 +223,7 @@ public void configure(final Task task) {
225223

226224
// ... Note 1: In real usage (i.e. no test scenario) item has name "classpathentry".
227225

228-
final Optional<Node> oChild = item.children().stream() // loop over all children
229-
.filter(c -> c instanceof Node) // better safe than sorry
226+
final Optional<Node> oChild = children(item) // loop over all children
230227
.filter(c -> NAME_CHILD.equals(((Node)c).name())) // with name "attributes"
231228
.findFirst(); // first child named "attributes"
232229

@@ -267,8 +264,7 @@ public void configure(final Task task) {
267264
/* package */ Optional<Node> getAttributeNamed(final Node child, final String name) {
268265
// ... Note 1: In real usage (i.e. no test scenario) node has name "attributes".
269266

270-
return child.children().stream() // loop over all children
271-
.filter(g -> g instanceof Node) // better safe than sorry
267+
return children(child) // loop over all children
272268
.filter(g -> NAME_GRAND.equals(((Node)g).name())) // nodes with name "attribute"
273269
.filter(g -> name.equals(((Node)g).attribute("name"))) // nodes with appropriate attribute
274270
.findFirst();
@@ -287,8 +283,7 @@ public void configure(final Task task) {
287283
/* package */ boolean hasNoAttributeModule(final Node item) {
288284
// ... Note 1: In real usage (i.e. no test scenario) item has name "classpathentry".
289285

290-
return item.children().stream() // loop over all children
291-
.filter(c -> c instanceof Node) // better safe than sorry
286+
return children(item) // loop over all children
292287
.filter(c -> NAME_CHILD.equals(((Node)c).name())) // child named "attributes"
293288
.filter(c -> hasAttributeNamed((Node)c, "module")) // grand-child with attribute "module"
294289
.findFirst()
@@ -308,8 +303,7 @@ public void configure(final Task task) {
308303
/* package */ boolean hasNoAttributeTest(final Node item) {
309304
// ... Note 1: In real usage (i.e. no test scenario) item has name "classpathentry".
310305

311-
return item.children().stream() // loop over all children
312-
.filter(c -> c instanceof Node) // better safe than sorry
306+
return children(item) // loop over all children
313307
.filter(c -> NAME_CHILD.equals(((Node)c).name())) // child named "attributes"
314308
.filter(c -> hasAttributeNamed((Node)c, "test")) // grand-child with attribute "test"
315309
.findFirst()
@@ -437,8 +431,7 @@ public void run() {
437431
map.put("value", "true");
438432

439433
// --- find first child named "attributes"
440-
item.children().stream() // loop over all children
441-
.filter(c -> c instanceof Node) // better safe than sorry
434+
children(item) // loop over all children
442435
.filter(c -> NAME_CHILD.equals(((Node)c).name())) // nodes with name "attributes"
443436
.findFirst()
444437
.ifPresentOrElse(
@@ -452,4 +445,11 @@ public void run() {
452445
new AddAttribute(item, map)
453446
); // end ifPresentOrElse(...)
454447
} // end method */
448+
449+
@SuppressWarnings("unchecked")
450+
private static Stream<Node> children(final Node item) {
451+
return item.children().stream()
452+
.filter(c -> c instanceof Node)
453+
.map(Node.class::cast);
454+
}
455455
} // end class

src/test/java/org/javamodularity/moduleplugin/tasks/CompileJavaTaskMutatorTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
class CompileJavaTaskMutatorTest {
2020

21+
@SuppressWarnings("deprecation")
2122
@Test
2223
void modularizeJavaCompileTask() {
2324
// given

0 commit comments

Comments
 (0)