Treat warnings as errors when compiling
See gh-21271
This commit is contained in:
@@ -25,6 +25,7 @@ import java.util.function.Consumer;
|
||||
|
||||
import io.spring.javaformat.gradle.FormatTask;
|
||||
import io.spring.javaformat.gradle.SpringJavaFormatPlugin;
|
||||
import org.gradle.api.JavaVersion;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
import org.gradle.api.artifacts.ConfigurationContainer;
|
||||
@@ -56,7 +57,13 @@ import org.springframework.boot.build.testing.TestFailuresPlugin;
|
||||
* <li>{@link Test} tasks are configured to use JUnit Platform and use a max heap of 1024M
|
||||
* <li>{@link JavaCompile}, {@link Javadoc}, and {@link FormatTask} tasks are configured
|
||||
* to use UTF-8 encoding
|
||||
* <li>{@link JavaCompile} tasks are configured to use {@code -parameters}
|
||||
* <li>{@link JavaCompile} tasks are configured to use {@code -parameters} and, when
|
||||
* compiling with Java 8, to:
|
||||
* <ul>
|
||||
* <li>Treat warnings as errors
|
||||
* <li>Enable {@code unchecked}, {@code deprecation}, {@code rawtypes}, and {@code varags}
|
||||
* warnings
|
||||
* </ul>
|
||||
* <li>{@link Jar} tasks are configured to produce jars with LICENSE.txt and NOTICE.txt
|
||||
* files and the following manifest entries:
|
||||
* <ul>
|
||||
@@ -149,6 +156,9 @@ class JavaConventions {
|
||||
if (!args.contains("-parameters")) {
|
||||
args.add("-parameters");
|
||||
}
|
||||
if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
|
||||
args.add("-Werror");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache;
|
||||
import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters;
|
||||
import org.springframework.boot.test.autoconfigure.json.AutoConfigureJson;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
@@ -55,9 +54,10 @@ import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
* {@link WebTestClient}. For more fine-grained control of WebTestClient the
|
||||
* {@link AutoConfigureWebTestClient @AutoConfigureWebTestClient} annotation can be used.
|
||||
* <p>
|
||||
* Typically {@code @WebFluxTest} is used in combination with {@link MockBean @MockBean}
|
||||
* or {@link Import @Import} to create any collaborators required by your
|
||||
* {@code @Controller} beans.
|
||||
* Typically {@code @WebFluxTest} is used in combination with
|
||||
* {@link org.springframework.boot.test.mock.mockito.MockBean @MockBean} or
|
||||
* {@link Import @Import} to create any collaborators required by your {@code @Controller}
|
||||
* beans.
|
||||
* <p>
|
||||
* If you are looking to load your full application configuration and use WebTestClient,
|
||||
* you should consider {@link SpringBootTest @SpringBootTest} combined with
|
||||
|
||||
@@ -31,7 +31,6 @@ import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration;
|
||||
import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache;
|
||||
import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
@@ -56,7 +55,8 @@ import org.springframework.test.web.servlet.MockMvc;
|
||||
* WebDriver). For more fine-grained control of MockMVC the
|
||||
* {@link AutoConfigureMockMvc @AutoConfigureMockMvc} annotation can be used.
|
||||
* <p>
|
||||
* Typically {@code @WebMvcTest} is used in combination with {@link MockBean @MockBean} or
|
||||
* Typically {@code @WebMvcTest} is used in combination with
|
||||
* {@link org.springframework.boot.test.mock.mockito.MockBean @MockBean} or
|
||||
* {@link Import @Import} to create any collaborators required by your {@code @Controller}
|
||||
* beans.
|
||||
* <p>
|
||||
|
||||
@@ -15,6 +15,7 @@ sourceSets {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompileOnly("com.google.code.findbugs:jsr305:3.0.2")
|
||||
testImplementation(enforcedPlatform(project(":spring-boot-project:spring-boot-dependencies")))
|
||||
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
|
||||
testImplementation("javax.validation:validation-api")
|
||||
|
||||
@@ -65,3 +65,9 @@ processResources {
|
||||
dependsOn reproducibleLoaderJar
|
||||
dependsOn reproducibleJarModeLayerToolsJar
|
||||
}
|
||||
|
||||
compileJava {
|
||||
if ((!project.hasProperty("buildJavaHome")) && JavaVersion.current() == JavaVersion.VERSION_1_8) {
|
||||
options.compilerArgs += ['-Xlint:-sunapi', '-XDenableSunApiLintControl']
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user