Enable deprecation compilation warnings

See gh-21271
This commit is contained in:
Andy Wilkinson
2020-06-04 12:58:29 +01:00
parent c64649a6d9
commit 056d5f3120
47 changed files with 182 additions and 168 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,12 +19,11 @@ package org.springframework.boot.gradle.plugin;
import org.gradle.api.Action;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.maven.MavenResolver;
import org.gradle.api.plugins.MavenPlugin;
import org.gradle.api.tasks.Upload;
/**
* {@link Action} that is executed in response to the {@link MavenPlugin} being applied.
* {@link Action} that is executed in response to the
* {@link org.gradle.api.plugins.MavenPlugin} being applied.
*
* @author Andy Wilkinson
*/
@@ -37,8 +36,9 @@ final class MavenPluginAction implements PluginApplicationAction {
}
@Override
@SuppressWarnings("deprecation")
public Class<? extends Plugin<? extends Project>> getPluginClass() {
return MavenPlugin.class;
return org.gradle.api.plugins.MavenPlugin.class;
}
@Override
@@ -50,8 +50,9 @@ final class MavenPluginAction implements PluginApplicationAction {
});
}
@SuppressWarnings("deprecation")
private void clearConfigurationMappings(Upload upload) {
upload.getRepositories().withType(MavenResolver.class,
upload.getRepositories().withType(org.gradle.api.artifacts.maven.MavenResolver.class,
(resolver) -> resolver.getPom().getScopeMappings().getMappings().clear());
}

View File

@@ -208,11 +208,13 @@ public class BootJar extends Jar implements BootArchive {
}
@Override
@Deprecated
public boolean isExcludeDevtools() {
return this.support.isExcludeDevtools();
}
@Override
@Deprecated
public void setExcludeDevtools(boolean excludeDevtools) {
this.support.setExcludeDevtools(excludeDevtools);
}

View File

@@ -165,11 +165,13 @@ public class BootWar extends War implements BootArchive {
}
@Override
@Deprecated
public boolean isExcludeDevtools() {
return this.support.isExcludeDevtools();
}
@Override
@Deprecated
public void setExcludeDevtools(boolean excludeDevtools) {
this.support.setExcludeDevtools(excludeDevtools);
}

View File

@@ -81,6 +81,7 @@ class BootWarTests extends AbstractBootArchiveTests<BootWar> {
}
@Test
@Deprecated
void devtoolsJarCanBeIncludedWhenItsOnTheProvidedClasspath() throws IOException {
getTask().setMainClassName("com.example.Main");
getTask().providedClasspath(jarFile("spring-boot-devtools-0.1.2.jar"));

View File

@@ -103,6 +103,7 @@ public class ExplodedArchive implements Archive {
}
@Override
@Deprecated
public Iterator<Entry> iterator() {
return new EntryIterator(this.root, this.recursive, null, null);
}
@@ -321,6 +322,7 @@ public class ExplodedArchive implements Archive {
}
@Override
@Deprecated
public Iterator<Entry> iterator() {
return Collections.emptyIterator();
}

View File

@@ -81,6 +81,7 @@ public class JarFileArchive implements Archive {
}
@Override
@Deprecated
public Iterator<Entry> iterator() {
return new EntryIterator(this.jarFile.iterator(), null, null);
}

View File

@@ -25,6 +25,7 @@ import java.net.URLClassLoader;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.jar.Attributes;
@@ -289,7 +290,7 @@ class PropertiesLauncherTests {
assertThat(loader.getClass().getName()).isEqualTo(TestLoader.class.getName());
}
private List<Archive> archives() throws Exception {
private Iterator<Archive> archives() throws Exception {
List<Archive> archives = new ArrayList<>();
String path = System.getProperty("java.class.path");
for (String url : path.split(File.pathSeparator)) {
@@ -298,7 +299,7 @@ class PropertiesLauncherTests {
archives.add(archive);
}
}
return archives;
return archives.iterator();
}
private Archive archive(String url) throws IOException {

View File

@@ -148,6 +148,7 @@ class JarFileArchiveTests {
File file = new File(this.tempDir, "test.jar");
FileCopyUtils.copy(writeZip64Jar(), file);
try (JarFileArchive zip64Archive = new JarFileArchive(file)) {
@SuppressWarnings("deprecation")
Iterator<Entry> entries = zip64Archive.iterator();
for (int i = 0; i < 65537; i++) {
assertThat(entries.hasNext()).as(i + "nth file is present").isTrue();