Skip to content

Commit

Permalink
Upgrade to Gradle 8 and latest plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
pantherdd committed Sep 15, 2023
1 parent 7607bef commit fa331b6
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 31 deletions.
26 changes: 12 additions & 14 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,30 @@ buildscript {
tasks.wrapper {
// When new Gradle versions become available, update `ApplicationPluginFunctionalTest.supportedGradleVersions` too
// See: https://gradle.org/releases/
gradleVersion = "7.5.1"
gradleVersion = "8.3"
distributionType = Wrapper.DistributionType.ALL
}
// --- ========== ---

plugins {
`java-library`
`java-gradle-plugin`
`maven-publish`
id("com.gradle.plugin-publish").version("1.0.0")
id("com.gradle.plugin-publish").version("1.2.1")
checkstyle
pmd
id("com.github.spotbugs").version("5.0.13")
id("com.github.spotbugs").version("5.1.3")
jacoco
}

group = "com.ms.gradle"
version = "2.0.0"
version = "2.0.1"

val pluginId = "com.ms.gradle.application"
val pluginClass = "com.ms.gradle.application.ApplicationPlugin"
require(pluginId == "${project.group}.${project.name}".replace("-", "")) { "Inconsistent naming: pluginId" }
require(pluginClass == "${pluginId}.${project.name.capitalize()}Plugin") { "Inconsistent naming: pluginClass" }
fun toPackageName(str: String) = str.replace("-", "")
fun toClassName(str: String) = str.replace(Regex("(^|-).")) { it.value.last().titlecase() }
require(pluginId == "${project.group}.${project.name}") { "Inconsistent pluginId" }
require(pluginClass == "${toPackageName(pluginId)}.${toClassName(project.name)}Plugin") { "Inconsistent pluginClass" }

val productVendor = "Morgan Stanley"
val productTitle = "Application plugin for Gradle"
Expand Down Expand Up @@ -84,20 +85,17 @@ val gitStatus = try {
}

gradlePlugin {
website.set(productUrl)
vcsUrl.set("${productUrl}.git")
plugins.create(project.name) {
id = pluginId
implementationClass = pluginClass
displayName = productTitle
description = productDescription
tags.set(productTags)
}
}

pluginBundle {
website = productUrl
vcsUrl = productUrl
pluginTags = mapOf(project.name to productTags)
}

val manifestAttributes by lazy {
val compileTask = tasks.compileJava.get()
mapOf(
Expand Down Expand Up @@ -218,7 +216,7 @@ tasks.withType<Jar> {
}

checkstyle {
toolVersion = "10.4"
toolVersion = "10.12.3"
maxErrors = 0
maxWarnings = 0
}
Expand Down
12 changes: 6 additions & 6 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Checkstyle configuration based on the Google Java Style Guide.
References:
* https://google.github.io/styleguide/javaguide.html
* https://github.com/checkstyle/checkstyle/blob/checkstyle-10.4/src/main/resources/google_checks.xml
* https://github.com/checkstyle/checkstyle/blob/checkstyle-10.12.3/src/main/resources/google_checks.xml
* http://checkstyle.org
-->

Expand All @@ -20,19 +20,19 @@ References:

<property name="fileExtensions" value="java, properties, xml"/>
<!-- Excludes all 'module-info.java' files -->
<!-- See https://checkstyle.org/config_filefilters.html -->
<!-- See https://checkstyle.org/filefilters/index.html -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>
<!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
<!-- https://checkstyle.org/filters/suppressionfilter.html -->
<module name="SuppressionFilter">
<property name="file" value="${org.checkstyle.google.suppressionfilter.config}"
default="checkstyle-suppressions.xml" />
<property name="optional" value="true"/>
</module>

<!-- Checks for whitespace -->
<!-- See http://checkstyle.org/config_whitespace.html -->
<!-- See http://checkstyle.org/checks/whitespace/index.html -->
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
Expand Down Expand Up @@ -92,7 +92,7 @@ References:
<property name="tokens"
value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT,
INSTANCE_INIT, ANNOTATION_DEF, ENUM_DEF, INTERFACE_DEF, RECORD_DEF,
COMPACT_CTOR_DEF"/>
COMPACT_CTOR_DEF, LITERAL_SWITCH"/>
</module>
<module name="SuppressionXpathSingleFilter">
<!-- suppresion is required till https://github.com/checkstyle/checkstyle/issues/7541 -->
Expand Down Expand Up @@ -358,7 +358,7 @@ References:
<module name="CommentsIndentation">
<property name="tokens" value="SINGLE_LINE_COMMENT, BLOCK_COMMENT_BEGIN"/>
</module>
<!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter -->
<!-- https://checkstyle.org/filters/suppressionxpathfilter.html -->
<module name="SuppressionXpathFilter">
<property name="file" value="${org.checkstyle.google.suppressionxpathfilter.config}"
default="checkstyle-xpath-suppressions.xml" />
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
25 changes: 17 additions & 8 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +80,11 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,22 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,6 +198,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
1 change: 1 addition & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ private static Stream<GradleVersion> gradleVersions(@Nonnull GradleVersion versi
// See: https://gradle.org/releases/
@Nonnull
private static Stream<GradleVersion> supportedGradleVersions() {
return gradleVersions(CURRENT_GRADLE_VERSION, "7.4.2", "7.3.3", "7.2", "7.1.1", "7.0.2",
"6.9.3", "6.8.3", "6.7.1", "6.6.1", "6.5.1", "6.4.1", "6.3", "6.2.2", "6.1.1", "6.0.1");
return gradleVersions(CURRENT_GRADLE_VERSION, "8.2.1", "8.1.1", "8.0.2",
"7.6.2", "7.5.1", "7.4.2", "7.3.3", "7.2", "7.1.1", "7.0.2",
"6.9.4", "6.8.3", "6.7.1", "6.6.1", "6.5.1", "6.4.1", "6.3", "6.2.2", "6.1.1", "6.0.1");
}

private enum GradleDsl {
Expand Down

0 comments on commit fa331b6

Please sign in to comment.