diff --git a/.gitattributes b/.gitattributes index b0030921..5850215f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -13,3 +13,5 @@ # Java-friendly readable chunk headers *.java diff=java + +/gradlew.bat eol=crlf diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ca879973..9ac715e6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,17 +8,17 @@ jobs: fail-fast: false matrix: version: - - { jdk: 11, idea: 2022.1 } - - { jdk: 17, idea: 2022.2 } - - { jdk: 17, idea: 2022.3 } - - { jdk: 17, idea: 2023.1 } - - { jdk: 17, idea: 2023.2 } - - { jdk: 17, idea: 2023.3 } - - { jdk: 17, idea: 2024.1 } - - { jdk: 17, idea: LATEST-EAP-SNAPSHOT } + - { jdk: 17, idea: 2022.2, eap: false } + - { jdk: 17, idea: 2022.3, eap: false } + - { jdk: 17, idea: 2023.1, eap: false } + - { jdk: 17, idea: 2023.2, eap: false } + - { jdk: 17, idea: 2023.3, eap: false } + - { jdk: 17, idea: 2024.1, eap: false } + - { jdk: 21, idea: LATEST-EAP-SNAPSHOT, eap: true } name: 'IDEA ${{ matrix.version.idea }}' env: IDEA_VERSION: ${{ matrix.version.idea }} + IDEA_EAP: ${{ matrix.version.eap }} runs-on: ubuntu-latest steps: - name: 'Checkout' diff --git a/README.md b/README.md index 47f98315..3f689db5 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ To learn more about MapStruct have a look at the [mapstruct](https://github.com/ ## Requirements -The MapStruct plugin requires Java 11 or later +The MapStruct plugin requires Java 17 or later ## Building from Source diff --git a/build.gradle b/build.gradle index adc4621e..db1cdeef 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ import com.hierynomus.gradle.license.tasks.LicenseCheck import com.hierynomus.gradle.license.tasks.LicenseFormat plugins { - id "org.jetbrains.intellij" version "1.16.1" + id "org.jetbrains.intellij" version "1.17.3" id "com.github.hierynomus.license" version "0.16.1" id "de.undercouch.download" version "5.4.0" } @@ -18,8 +18,10 @@ apply plugin: 'license' apply plugin: 'checkstyle' apply plugin: 'jacoco' -sourceCompatibility = 11 -targetCompatibility = 11 +java { + sourceCompatibility = 17 + targetCompatibility = 17 +} repositories { mavenLocal() @@ -30,7 +32,7 @@ intellij { version = System.getenv().getOrDefault('IDEA_VERSION', ideaVersion) type = ideaType downloadSources = Boolean.valueOf(sources) - sameSinceUntilBuild = Boolean.valueOf(isEAP) + sameSinceUntilBuild = Boolean.valueOf(System.getenv().getOrDefault('IDEA_EAP', isEAP)) instrumentCode = false updateSinceUntilBuild = false pluginName = 'MapStruct-Intellij-Plugin' @@ -47,20 +49,18 @@ patchPluginXml { pluginDescription = htmlFixer('description.html') } -task licenseTestData(type: LicenseCheck) { +tasks.register "licenseTestData", LicenseCheck, { source = fileTree(dir: "testData").include("**/*") } -task licenseFormatForKotlin(type: LicenseFormat) { +tasks.register "licenseFormatForKotlin", LicenseFormat, { source = fileTree(dir: "src/main").include("**/*.kt").include("**/*.xml") } license { header rootProject.file('etc/license.txt') strictCheck true - mapping { - java = 'SLASHSTAR_STYLE' // IntelliJ reports the JAVADOC_STYLE as a dangling comment - } + mapping('java', 'SLASHSTAR_STYLE') // IntelliJ reports the JAVADOC_STYLE as a dangling comment excludes([ '**/META-INF/plugin.xml', // For some reason the plugin thinks that the license is not valid '**/*.properties', @@ -72,18 +72,13 @@ licenseFormat.dependsOn licenseFormatForKotlin licenseTest.dependsOn licenseTestData checkstyle { - toolVersion '8.36.1' config resources.text.fromUri("https://raw.githubusercontent.com/mapstruct/mapstruct/master/build-config/src/main/resources/build-config/checkstyle.xml") configProperties = [ - 'checkstyle.cache.file': rootProject.buildDir.toPath().resolve('checkstyle-cachefile').toString(), + 'checkstyle.cache.file': rootProject.layout.buildDirectory.get().asFile.toPath().resolve('checkstyle-cachefile').toString(), 'basedir': 'https://raw.githubusercontent.com/mapstruct/mapstruct/master/build-config', ] } -jacoco { - toolVersion "0.8.11" -} - jacocoTestReport { reports { xml.required = true @@ -92,27 +87,29 @@ jacocoTestReport { } dependencies { - implementation('org.mapstruct:mapstruct:1.5.3.Final') - testImplementation(platform('org.junit:junit-bom:5.8.2')) + implementation("org.mapstruct:mapstruct:${mapstructVersion}") + testImplementation(platform('org.junit:junit-bom:5.10.2')) testImplementation('org.junit.platform:junit-platform-launcher') testImplementation('org.junit.jupiter:junit-jupiter-api') testImplementation('org.junit.jupiter:junit-jupiter-engine') testRuntimeOnly('org.junit.vintage:junit-vintage-engine') - testImplementation('org.assertj:assertj-core:3.11.1') - testImplementation('org.apache.commons:commons-text:1.10.0') + testImplementation('org.assertj:assertj-core:3.26.0') + testImplementation('org.apache.commons:commons-text:1.12.0') } -task libs(type: Sync) { +tasks.register "libs", Sync, { from configurations.runtimeClasspath - into "$buildDir/libs" + into "${layout.buildDirectory.get().asFile}/libs" preserve { include 'mapstruct-intellij-*.jar' } - rename 'mapstruct-1.5.3.Final.jar', 'mapstruct.jar' + rename "mapstruct-${mapstructVersion}.jar", 'mapstruct.jar' } def mockJdkLocation = "https://github.com/JetBrains/intellij-community/raw/212.5712/java/mock" -def mockJdkDest = "$buildDir/mock" +def mockJdkDest = "${layout.buildDirectory.get().asFile}/mock" + +@SuppressWarnings('GrMethodMayBeStatic') def downloadMockJdk(mockJdkLocation, mockJdkDest, mockJdkVersion) { def location = mockJdkLocation + mockJdkVersion def destination = mockJdkDest + mockJdkVersion @@ -127,7 +124,7 @@ def downloadMockJdk(mockJdkLocation, mockJdkDest, mockJdkVersion) { } } -task downloadMockJdk7() { +tasks.register "downloadMockJdk7", { def jdkVersion = "JDK-1.7" def mockJdk7Location = mockJdkLocation + jdkVersion def mockJdk7Dest = mockJdkDest + jdkVersion @@ -142,17 +139,18 @@ task downloadMockJdk7() { } } -task downloadMockJdk8() { +tasks.register "downloadMockJdk8", { downloadMockJdk(mockJdkLocation, mockJdkDest, "JDK-1.8") } -task downloadMockJdk11() { +tasks.register "downloadMockJdk11", { downloadMockJdk(mockJdkLocation, mockJdkDest, "JDK-11") } test.dependsOn( libs, downloadMockJdk7, downloadMockJdk8, downloadMockJdk11 ) prepareTestingSandbox.dependsOn( libs ) prepareSandbox.dependsOn( libs ) +classpathIndexCleanup.mustRunAfter compileTestJava // a workaround for a someone else's bug test { // Idea SDK needs special configuration diff --git a/gradle.properties b/gradle.properties index 2b4ca168..0f5ecded 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ # https://www.jetbrains.com/intellij-repository/releases # https://www.jetbrains.com/intellij-repository/snapshots -ideaVersion = 2022.1 +ideaVersion = 2022.2 ideaType = IC sources = true isEAP = false @@ -12,6 +12,8 @@ pluginGroup = org.mapstruct pluginName = mapstruct-intellij pluginVersion = 1.7.1-SNAPSHOT +mapstructVersion = 1.5.5.Final + publishPluginId = publishUsername = publishPassword = diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e5832..e6441136 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 fae08049..381baa9c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,8 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionSha256Sum=544c35d6bd849ae8a5ed0bcea39ba677dc40f49df7d1835561582da2009b961d +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index a69d9cb6..1aa94a42 100755 --- a/gradlew +++ b/gradlew @@ -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/. @@ -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 @@ -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=SC2039,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=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# 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 -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# 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, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/gradlew.bat b/gradlew.bat index f127cfd4..25da30db 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -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% @@ -42,11 +43,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 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. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -56,11 +57,11 @@ 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. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/src/main/java/org/mapstruct/intellij/util/MapstructUtil.java b/src/main/java/org/mapstruct/intellij/util/MapstructUtil.java index ceb4559a..b1689382 100644 --- a/src/main/java/org/mapstruct/intellij/util/MapstructUtil.java +++ b/src/main/java/org/mapstruct/intellij/util/MapstructUtil.java @@ -154,9 +154,9 @@ public static LookupElement asLookupWithRepresentableText(PsiMethod method, Stri return builder; } + @SuppressWarnings("unchecked") public static LookupElement asLookup(String propertyName, @NotNull T psiElement, Function typeMapper, Icon icon) { - //noinspection unchecked return asLookup( propertyName, Pair.pair( psiElement, EmptySubstitutor.getInstance() ), (Function) typeMapper, icon ); diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 177692f9..3a561998 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -24,7 +24,7 @@ MapStruct - +