@@ -546,12 +546,46 @@ ext.IS_RELEASE = !ext.IS_DEBUG_JAVA
546
546
defineProperty(" MAVEN_PUBLISH" , " false" )
547
547
ext. IS_MAVEN_PUBLISH = Boolean . parseBoolean(MAVEN_PUBLISH )
548
548
549
- // Defines the compiler warning levels to use. If empty, then no warnings are generated. If
550
- // not empty, then the expected syntax is as a space or comma separated list of names, such
551
- // as defined in the javac documentation.
552
- defineProperty(" LINT" , " none" )
553
- ext. IS_LINT = LINT != " none"
549
+ // Define the compiler lint warnings to enable.
550
+ //
551
+ // We define a separate set of options for normal classes, test classes
552
+ // (including shims), and tool classes (including JSLC).
553
+ // A project (module) can add project-specific lint options for each
554
+ // category if desired.
555
+ // extraLintOptions
556
+ // extraToolLintOptions
557
+ // extraTestLintOptions
558
+ //
559
+ // The lint options can be overriden on the command line. If set to the
560
+ // empty string, then no lint warnings are enabled; even project-specific
561
+ // lint options are disabled. If not empty, then it is parsed as a space
562
+ // or comma separated list of names. See the javac documentation for a list
563
+ // of valid lint options.
564
+
565
+ def defaultLintOptions =
566
+ " removal" + " ," +
567
+ " missing-explicit-ctor"
568
+ defineProperty(" LINT" , defaultLintOptions)
569
+ ext. IS_LINT = LINT != " "
570
+
571
+ def defaultToolLintOptions = " "
572
+ defineProperty(" TOOL_LINT" , defaultToolLintOptions)
573
+ ext. IS_TOOL_LINT = TOOL_LINT != " "
574
+
575
+ def defaultTestLintOptions = " "
576
+ defineProperty(" TEST_LINT" , defaultTestLintOptions)
577
+ ext. IS_TEST_LINT = TEST_LINT != " "
578
+
579
+ defineProperty(" JAVAC_WERROR" , " true" )
580
+ ext. IS_JAVAC_WERROR = Boolean . parseBoolean(JAVAC_WERROR )
581
+
582
+ defineProperty(" TOOL_JAVAC_WERROR" , " false" )
583
+ ext. IS_TOOL_JAVAC_WERROR = Boolean . parseBoolean(TOOL_JAVAC_WERROR )
554
584
585
+ defineProperty(" TEST_JAVAC_WERROR" , " false" )
586
+ ext. IS_TEST_JAVAC_WERROR = Boolean . parseBoolean(TEST_JAVAC_WERROR )
587
+
588
+ // Doclint options (all enabled by default)
555
589
defineProperty(" DOC_LINT" , " all" )
556
590
ext. IS_DOC_LINT = DOC_LINT != " "
557
591
@@ -1731,7 +1765,7 @@ void addMavenPublication(Project project, List<String> projectDependencies) {
1731
1765
afterEvaluate {
1732
1766
artifact project. tasks. " moduleEmptyPublicationJar$t. capital "
1733
1767
artifact project. tasks. " modularPublicationJar$t. capital " {
1734
- classifier " $t. name "
1768
+ archiveClassifier . set( " $t. name " )
1735
1769
}
1736
1770
}
1737
1771
@@ -2159,6 +2193,11 @@ project(":base") {
2159
2193
project. ext. moduleRuntime = true
2160
2194
project. ext. moduleName = " javafx.base"
2161
2195
2196
+ // TODO: the following is an example of enabling module-specific lint opts
2197
+ // project.ext.extraLintOptions =
2198
+ // "deprecation" + "," +
2199
+ // "divzero"
2200
+
2162
2201
sourceSets {
2163
2202
main
2164
2203
shims {
@@ -2228,6 +2267,10 @@ project(":graphics") {
2228
2267
project. ext. moduleRuntime = true
2229
2268
project. ext. moduleName = " javafx.graphics"
2230
2269
2270
+ // FIXME: Remove this setting when JDK-8334137 is fixed
2271
+ // Disable javac -Werror until we stop using sun.misc.Unsafe
2272
+ project. ext. disableJavacWerror = true
2273
+
2231
2274
getConfigurations(). create(" antlr" );
2232
2275
2233
2276
sourceSets {
@@ -2760,6 +2803,11 @@ project(":swing") {
2760
2803
// "-source NN -target NN" for this module.
2761
2804
project. ext. skipJavaCompilerOptionRelease = true
2762
2805
2806
+ // We also need to disable the implicitly-enabled lint warning that
2807
+ // results from the above
2808
+ project. ext. extraLintOptions =
2809
+ " -options"
2810
+
2763
2811
tasks. all {
2764
2812
if (! COMPILE_SWING ) it. enabled = false
2765
2813
}
@@ -4043,6 +4091,20 @@ project(":systemTests") {
4043
4091
addValidateSourceSets(project, nonModSrcSets, modSrcSets)
4044
4092
}
4045
4093
4094
+ void setupLintOptions (Task compile , String lintOpts , String extraLintOpts ) {
4095
+ lintOpts. split(" [, ]" ). each { s ->
4096
+ compile. options. compilerArgs + = " -Xlint:$s "
4097
+ }
4098
+
4099
+ if (extraLintOpts != " " ) {
4100
+ extraLintOpts. split(" [, ]" ). each { s ->
4101
+ compile. options. compilerArgs + = " -Xlint:$s "
4102
+ }
4103
+ }
4104
+
4105
+ compile. options. compilerArgs + = [ " -Xmaxwarns" , " 1000" ]
4106
+ }
4107
+
4046
4108
allprojects {
4047
4109
// The following block is a workaround for the fact that presently Gradle
4048
4110
// can't set the -XDignore.symbol.file flag, because it appears that the
@@ -4071,18 +4133,64 @@ allprojects {
4071
4133
4072
4134
compile. options. forkOptions. executable = JAVAC
4073
4135
4074
- compile. options. warnings = IS_LINT
4075
-
4076
4136
compile. options. compilerArgs + = [" -XDignore.symbol.file" , " -encoding" , " UTF-8" ]
4137
+ compile. options. compilerArgs + = [ " -Xmaxerrs" , " 1000" ]
4077
4138
4078
4139
// we use a custom javadoc command
4079
4140
project. javadoc. enabled = false
4080
4141
4081
- // Add in the -Xlint options
4082
- if (IS_LINT ) {
4083
- LINT . split(" [, ]" ). each { s ->
4084
- compile. options. compilerArgs + = " -Xlint:$s "
4142
+ def disableJavacWerror =
4143
+ project. hasProperty(' disableJavacWerror' ) &&
4144
+ project. ext. disableJavacWerror
4145
+
4146
+ if (compile. name == " compileJava" ||
4147
+ compile. name == " compileFullJava" ||
4148
+ compile. name. startsWith(" compileJavaDOMBinding" )) {
4149
+
4150
+ // Add in the -Xlint options
4151
+ compile. options. warnings = IS_LINT
4152
+ if (IS_LINT ) {
4153
+ def extraLintOpts = project. hasProperty(" extraLintOptions" ) ?
4154
+ project. ext. extraLintOptions : " "
4155
+ setupLintOptions(compile, LINT , extraLintOpts);
4156
+
4157
+ if (IS_JAVAC_WERROR && ! disableJavacWerror) {
4158
+ compile. options. compilerArgs + = " -Werror"
4159
+ }
4160
+ }
4161
+ } else if (compile. name == " compileJslcJava" ||
4162
+ compile. name == " compileDecoraCompilers" ||
4163
+ compile. name == " compilePrismCompilers" ||
4164
+ compile. name == " compileToolsJava" ) {
4165
+
4166
+ // Add in the -Xlint options
4167
+ compile. options. warnings = IS_TOOL_LINT
4168
+ if (IS_TOOL_LINT ) {
4169
+ def extraLintOpts = project. hasProperty(" extraToolLintOptions" ) ?
4170
+ project. ext. extraToolLintOptions : " "
4171
+ setupLintOptions(compile, TOOL_LINT , extraLintOpts);
4172
+
4173
+ if (IS_TOOL_JAVAC_WERROR && ! disableJavacWerror) {
4174
+ compile. options. compilerArgs + = " -Werror"
4175
+ }
4085
4176
}
4177
+ } else if (compile. name == " compileShimsJava" ||
4178
+ compile. name. startsWith(" compileTest" )) {
4179
+
4180
+ // Add in the -Xlint options
4181
+ compile. options. warnings = IS_TEST_LINT
4182
+ if (IS_TEST_LINT ) {
4183
+ def extraLintOpts = project. hasProperty(" extraTestLintOptions" ) ?
4184
+ project. ext. extraTestLintOptions : " "
4185
+ setupLintOptions(compile, TEST_LINT , extraLintOpts);
4186
+
4187
+ if (IS_TEST_JAVAC_WERROR && ! disableJavacWerror) {
4188
+ compile. options. compilerArgs + = " -Werror"
4189
+ }
4190
+ }
4191
+ } else {
4192
+ logger. info(" Unknown compilation task: ${ project} :${ compile.name} " )
4193
+ compile. options. warnings = false
4086
4194
}
4087
4195
} // tasks with javaCompile
4088
4196
0 commit comments