diff --git a/.gitattributes b/.gitattributes index cc8847fd..2df98e02 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,34 @@ -*.java diff=java +* text=auto eol=lf +# Force Batch files to CRLF +*.bat eol=crlf -text +# Java sources +*.java text diff=java +*.kt text diff=java +*.gradle text diff=java +*.gradle.kts text diff=java + +# These files are text and should be normalized (Convert crlf => lf) +*.css text diff=css +*.df text +*.htm text diff=html +*.html text diff=html +*.js text +*.jsp text +*.jspf text +*.jspx text +*.properties text +*.tld text +*.tag text +*.tagx text +*.xml text + +# These files are binary and should be left untouched +# (binary is a macro for -text -diff) +*.class binary +*.dll binary +*.ear binary +*.jar binary +*.so binary +*.war binary +*.jks binary diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 6d018412..ef3a43b2 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -11,7 +11,7 @@ repositories { dependencies { implementation(gradleApi()) implementation("gradle.plugin.org.cadixdev.gradle:licenser:0.6.1") - implementation("org.ajoberstar.grgit:grgit-gradle:4.1.0") - implementation("com.github.jengelman.gradle.plugins:shadow:6.1.0") - implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.21.0") -} \ No newline at end of file + implementation("org.ajoberstar.grgit:grgit-gradle:4.1.1") + implementation("gradle.plugin.com.github.johnrengelman:shadow:7.1.2") + implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.27.1") +} diff --git a/buildSrc/src/main/kotlin/CommonConfig.kt b/buildSrc/src/main/kotlin/CommonConfig.kt index 2a01ea90..6126bb49 100644 --- a/buildSrc/src/main/kotlin/CommonConfig.kt +++ b/buildSrc/src/main/kotlin/CommonConfig.kt @@ -25,7 +25,7 @@ fun Project.applyCommonConfiguration() { plugins.withId("java") { the().toolchain { - languageVersion.set(JavaLanguageVersion.of(16)) + languageVersion.set(JavaLanguageVersion.of(17)) } } diff --git a/buildSrc/src/main/kotlin/CommonJavaConfig.kt b/buildSrc/src/main/kotlin/CommonJavaConfig.kt new file mode 100644 index 00000000..ca74a3b6 --- /dev/null +++ b/buildSrc/src/main/kotlin/CommonJavaConfig.kt @@ -0,0 +1,86 @@ +import org.gradle.api.Project +import org.gradle.api.plugins.JavaPluginExtension +import org.gradle.api.plugins.quality.CheckstyleExtension +import org.gradle.api.tasks.compile.JavaCompile +import org.gradle.api.tasks.javadoc.Javadoc +import org.gradle.api.tasks.testing.Test +import org.gradle.external.javadoc.StandardJavadocDocletOptions +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.get +import org.gradle.kotlin.dsl.withType + +fun Project.applyCommonJavaConfiguration(sourcesJar: Boolean, javaRelease: Int = 8, banSlf4j: Boolean = true) { + applyCommonConfiguration() + apply(plugin = "eclipse") + apply(plugin = "idea") + apply(plugin = "checkstyle") + + tasks + .withType() + .matching { it.name == "compileJava" || it.name == "compileTestJava" } + .configureEach { + val disabledLint = listOf( + "processing", "path", "fallthrough", "serial" + ) + options.release.set(javaRelease) + options.compilerArgs.addAll(listOf("-Xlint:all") + disabledLint.map { "-Xlint:-$it" }) + options.isDeprecation = true + options.encoding = "UTF-8" + options.compilerArgs.add("-parameters") + } + + configure { + configFile = rootProject.file("config/checkstyle/checkstyle.xml") + toolVersion = "9.1" + } + + tasks.withType().configureEach { + useJUnitPlatform() + } + + dependencies { + "compileOnly"("com.google.code.findbugs:jsr305:${Versions.FINDBUGS}") + "testImplementation"("org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT}") + "testImplementation"("org.junit.jupiter:junit-jupiter-params:${Versions.JUNIT}") + "testImplementation"("org.mockito:mockito-core:${Versions.MOCKITO}") + "testImplementation"("org.mockito:mockito-junit-jupiter:${Versions.MOCKITO}") + "testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:${Versions.JUNIT}") + } + + // Java 8 turns on doclint which we fail + tasks.withType().configureEach { + options.encoding = "UTF-8" + (options as StandardJavadocDocletOptions).apply { + addStringOption("Xdoclint:none", "-quiet") + tags( + "apiNote:a:API Note:", + "implSpec:a:Implementation Requirements:", + "implNote:a:Implementation Note:" + ) + } + } + + configure { + disableAutoTargetJvm() + withJavadocJar() + if (sourcesJar) { + withSourcesJar() + } + } + + if (banSlf4j) { + configurations["compileClasspath"].apply { + resolutionStrategy.componentSelection { + withModule("org.slf4j:slf4j-api") { + reject("No SLF4J allowed on compile classpath") + } + } + } + } + + tasks.named("check").configure { + dependsOn("checkstyleMain", "checkstyleTest") + } +} diff --git a/buildSrc/src/main/kotlin/GradleExtras.kt b/buildSrc/src/main/kotlin/GradleExtras.kt index e7d1e0ed..beedf160 100644 --- a/buildSrc/src/main/kotlin/GradleExtras.kt +++ b/buildSrc/src/main/kotlin/GradleExtras.kt @@ -1,6 +1,6 @@ import org.gradle.api.Project import org.gradle.api.plugins.ExtraPropertiesExtension -import org.gradle.api.plugins.JavaPluginConvention +import org.gradle.api.plugins.JavaPluginExtension import org.gradle.api.tasks.SourceSetContainer import org.gradle.kotlin.dsl.getByType import org.gradle.kotlin.dsl.the @@ -9,4 +9,4 @@ val Project.ext: ExtraPropertiesExtension get() = extensions.getByType() val Project.sourceSets: SourceSetContainer - get() = the().sourceSets + get() = the().sourceSets diff --git a/buildSrc/src/main/kotlin/LibsConfig.kt b/buildSrc/src/main/kotlin/LibsConfig.kt index 3a78ce60..9acb5a10 100644 --- a/buildSrc/src/main/kotlin/LibsConfig.kt +++ b/buildSrc/src/main/kotlin/LibsConfig.kt @@ -1,6 +1,7 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import org.gradle.api.Plugin import org.gradle.api.Project +import org.gradle.api.artifacts.ExternalModuleDependency import org.gradle.api.artifacts.ModuleDependency import org.gradle.api.attributes.Bundling import org.gradle.api.attributes.Category @@ -52,22 +53,22 @@ fun Project.applyLibrariesConfiguration() { } val altConfigFiles = { artifactType: String -> val deps = configurations["shade"].incoming.dependencies - .filterIsInstance() - .map { it.copy() } - .map { dependency -> - dependency.artifact { - name = dependency.name - type = artifactType - extension = "jar" - classifier = artifactType - } - dependency + .filterIsInstance() + .map { it.copy() } + .map { dependency -> + dependency.artifact { + name = dependency.name + type = artifactType + extension = "jar" + classifier = artifactType } + dependency + } files(configurations.detachedConfiguration(*deps.toTypedArray()) - .resolvedConfiguration.lenientConfiguration.artifacts - .filter { it.classifier == artifactType } - .map { zipTree(it.file) }) + .resolvedConfiguration.lenientConfiguration.artifacts + .filter { it.classifier == artifactType } + .map { zipTree(it.file) }) } tasks.register("sourcesJar") { from({ @@ -161,11 +162,26 @@ fun Project.applyLibrariesConfiguration() { applyCommonArtifactoryConfig() } +// A horrible hack because `softwareComponentFactory` has to be gotten via plugin +// gradle why internal open class LibsConfigPluginHack @Inject constructor( - private val softwareComponentFactory: SoftwareComponentFactory + private val softwareComponentFactory: SoftwareComponentFactory ) : Plugin { override fun apply(project: Project) { val libsComponents = softwareComponentFactory.adhoc("libs") project.components.add(libsComponents) } -} \ No newline at end of file +} + +fun Project.constrainDependenciesToLibsCore() { + evaluationDependsOn(":worldguard-libs:core") + val coreDeps = project(":worldguard-libs:core").configurations["shade"].dependencies + .filterIsInstance() + dependencies.constraints { + for (coreDep in coreDeps) { + add("shade", "${coreDep.group}:${coreDep.name}:${coreDep.version}") { + because("libs should align with libs:core") + } + } + } +} diff --git a/buildSrc/src/main/kotlin/PlatformConfig.kt b/buildSrc/src/main/kotlin/PlatformConfig.kt index 659af399..48fe104b 100644 --- a/buildSrc/src/main/kotlin/PlatformConfig.kt +++ b/buildSrc/src/main/kotlin/PlatformConfig.kt @@ -1,78 +1,30 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import org.gradle.api.Project import org.gradle.api.component.AdhocComponentWithVariants -import org.gradle.api.plugins.JavaPluginExtension -import org.gradle.api.plugins.quality.CheckstyleExtension import org.gradle.api.publish.PublishingExtension import org.gradle.api.publish.maven.MavenPublication -import org.gradle.api.tasks.javadoc.Javadoc -import org.gradle.api.tasks.testing.Test -import org.gradle.external.javadoc.StandardJavadocDocletOptions import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.dependencies import org.gradle.kotlin.dsl.get import org.gradle.kotlin.dsl.named import org.gradle.kotlin.dsl.register -import org.gradle.kotlin.dsl.withType -import org.gradle.kotlin.dsl.the -fun Project.applyPlatformAndCoreConfiguration() { +fun Project.applyPlatformAndCoreConfiguration(javaRelease: Int = 17) { applyCommonConfiguration() apply(plugin = "java") - apply(plugin = "eclipse") - apply(plugin = "idea") apply(plugin = "maven-publish") - apply(plugin = "checkstyle") apply(plugin = "com.jfrog.artifactory") + applyCommonJavaConfiguration( + sourcesJar = true, + javaRelease = javaRelease, + banSlf4j = false + ) ext["internalVersion"] = "$version+${rootProject.ext["gitCommitHash"]}" - configure { - configFile = rootProject.file("config/checkstyle/checkstyle.xml") - toolVersion = "8.34" - } - - tasks.withType().configureEach { - useJUnitPlatform() - } - - dependencies { - "compileOnly"("com.google.code.findbugs:jsr305:3.0.2") - "testCompileOnly"("com.google.code.findbugs:jsr305:3.0.2") - "testImplementation"("org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT}") - "testImplementation"("org.junit.jupiter:junit-jupiter-params:${Versions.JUNIT}") - "testImplementation"("org.mockito:mockito-core:${Versions.MOCKITO}") - "testImplementation"("org.mockito:mockito-junit-jupiter:${Versions.MOCKITO}") - "testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:${Versions.JUNIT}") - } - - // Java 8 turns on doclint which we fail - tasks.withType().configureEach { - (options as StandardJavadocDocletOptions).apply { - addStringOption("Xdoclint:none", "-quiet") - tags( - "apiNote:a:API Note:", - "implSpec:a:Implementation Requirements:", - "implNote:a:Implementation Note:" - ) - } - } - - the().withJavadocJar() - - if (name == "worldguard-core" || name == "worldguard-bukkit") { - the().withSourcesJar() - } - - tasks.named("check").configure { - dependsOn("checkstyleMain", "checkstyleTest") - } - configure { publications { register("maven") { - from(components["java"]) versionMapping { usage("java-api") { fromResolutionOf("runtimeClasspath") @@ -105,8 +57,10 @@ fun Project.applyShadowConfiguration() { exclude("GradleStart**") exclude(".cache") exclude("LICENSE*") + exclude("META-INF/maven/**") } val javaComponent = components["java"] as AdhocComponentWithVariants + // I don't think we want this published (it's the shadow jar) javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) { skip() } diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index f90e6d74..2c086d6c 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -1,9 +1,10 @@ object Versions { -// const val PISTON = "0.4.3" -// const val AUTO_VALUE = "1.6.5" - const val WORLDEDIT = "7.2.7" - const val JUNIT = "5.7.0" + const val WORLDEDIT = "7.2.9" + const val PISTON = "0.5.7" + const val AUTO_VALUE = "1.9" + const val JUNIT = "5.8.1" + const val MOCKITO = "4.3.1" const val SQUIRRELID = "0.3.0" const val GUAVA = "31.0.1-jre" - const val MOCKITO = "3.7.7" + const val FINDBUGS = "3.0.2" } diff --git a/gradle.properties b/gradle.properties index c2999356..2c13f50c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ group=com.sk89q.worldguard -version=7.0.8-SNAPSHOT +version=7.1.0-SNAPSHOT diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180f..41d9927a 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e750102e..00e33ede 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew.bat b/gradlew.bat index 107acd32..ac1b06f9 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,89 +1,89 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/worldguard-core/build.gradle.kts b/worldguard-core/build.gradle.kts index 35e2a22b..33be66e5 100644 --- a/worldguard-core/build.gradle.kts +++ b/worldguard-core/build.gradle.kts @@ -8,10 +8,10 @@ dependencies { "api"(project(":worldguard-libs:core")) "api"("com.sk89q.worldedit:worldedit-core:${Versions.WORLDEDIT}") "implementation"("org.flywaydb:flyway-core:3.0") - "implementation"("org.yaml:snakeyaml:1.29") + "implementation"("org.yaml:snakeyaml:1.30") "implementation"("com.google.guava:guava:${Versions.GUAVA}") - "compileOnly"("com.google.code.findbugs:jsr305:1.3.9") + "compileOnly"("com.google.code.findbugs:jsr305:${Versions.FINDBUGS}") "testImplementation"("org.hamcrest:hamcrest-library:1.2.1") } diff --git a/worldguard-libs/bukkit/build.gradle.kts b/worldguard-libs/bukkit/build.gradle.kts index 388618ce..7eb9124f 100644 --- a/worldguard-libs/bukkit/build.gradle.kts +++ b/worldguard-libs/bukkit/build.gradle.kts @@ -1 +1,2 @@ applyLibrariesConfiguration() +constrainDependenciesToLibsCore() \ No newline at end of file