Skip to content

Fix compiler warnings #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public void apply(Project project) {
new ModuleName().findModuleName(project).ifPresent(moduleName -> configureModularity(project, moduleName));
}

@SuppressWarnings("deprecation")
private void configureModularity(Project project, String moduleName) {
ExtensionContainer extensions = project.getExtensions();
extensions.add("moduleName", moduleName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public static void configure(Project project) {
project.afterEvaluate(container::configureAfterEvaluate);
}

@SuppressWarnings("deprecation")
private void configureAfterEvaluate(Project project) {
PatchModuleExtension patchModuleExtension = new JavaProjectHelper(project).extension(PatchModuleExtension.class);
patchModuleExtension.getConfig().forEach( config -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ public void setConfig(List<String> config) {
}

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

/** @deprecated As of 1.7.0, this method is no longer used and can be removed */
@SuppressWarnings("removal")
@Deprecated(since = "1.7.0", forRemoval = true)
public PatchModuleResolver resolvePatched(UnaryOperator<String> jarNameResolver) {
return new PatchModuleResolver(this, jarNameResolver);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.stream.Stream;
import org.gradle.api.Task;
import org.gradle.api.logging.Logger;
import org.gradle.api.logging.Logging;
Expand Down Expand Up @@ -132,8 +133,7 @@ public void configure(final Task task) {
// </attributes>
// </classpathentry>

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

rootNode.children().stream() // loop over all children
.filter(i -> i instanceof Node) // better safe than sorry
children(rootNode) // loop over all children
.filter(i -> NAME_ITEM.equals(((Node)i).name())) // with name "classpathentry"
.filter(i -> "test".equals(getGradleScope((Node)i))) // appropriate gradle scope
.filter(i -> hasNoAttributeTest((Node)i)) // without "test" information
Expand All @@ -193,8 +192,7 @@ public void configure(final Task task) {
* XML-content to be improved
*/
/* package */ void putJreOnModulePath(final Node rootNode) {
rootNode.children().stream() // loop over all children
.filter(i -> i instanceof Node) // better safe than sorry
children(rootNode) // loop over all children
.filter(i -> NAME_ITEM.equals(((Node)i).name())) // with name "classpathentry"
.filter(i -> isJre((Node)i)) // indicating JRE
.filter(i -> hasNoAttributeModule((Node)i)) // without "module" information
Expand Down Expand Up @@ -225,8 +223,7 @@ public void configure(final Task task) {

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

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

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

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

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

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

// --- find first child named "attributes"
item.children().stream() // loop over all children
.filter(c -> c instanceof Node) // better safe than sorry
children(item) // loop over all children
.filter(c -> NAME_CHILD.equals(((Node)c).name())) // nodes with name "attributes"
.findFirst()
.ifPresentOrElse(
Expand All @@ -452,4 +445,11 @@ public void run() {
new AddAttribute(item, map)
); // end ifPresentOrElse(...)
} // end method */

@SuppressWarnings("unchecked")
private static Stream<Node> children(final Node item) {
return item.children().stream()
.filter(c -> c instanceof Node)
.map(Node.class::cast);
}
} // end class
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

class CompileJavaTaskMutatorTest {

@SuppressWarnings("deprecation")
@Test
void modularizeJavaCompileTask() {
// given
Expand Down