diff --git a/.gitignore b/.gitignore index a42e1930ba6aca10b3cdb029fdaa70905aced2e7..df6966a18f6025eaa1df3e9698e2b7e78759ce4b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,7 @@ -# Created by .ignore support plugin (hsz.mobi) -build -idea-sandbox -/out/ -/MybatisX.iml -.gradle/ +.DS_Store +.gradle .idea -*.iml .intellijPlatform +.kotlin +.qodana +build diff --git a/.run/Run Plugin.run.xml b/.run/Run Plugin.run.xml new file mode 100644 index 0000000000000000000000000000000000000000..00a760e54d26b347f7b2cee03bcf199d699ef764 --- /dev/null +++ b/.run/Run Plugin.run.xml @@ -0,0 +1,25 @@ + + + + + + + + true + true + false + false + + + diff --git a/.run/Run Tests.run.xml b/.run/Run Tests.run.xml new file mode 100644 index 0000000000000000000000000000000000000000..f281bdc83e4c6e9d6b1d0c5857fb1c9cfcfc1745 --- /dev/null +++ b/.run/Run Tests.run.xml @@ -0,0 +1,25 @@ + + + + + + + + true + true + false + true + + + diff --git a/.run/Run Verifications.run.xml b/.run/Run Verifications.run.xml new file mode 100644 index 0000000000000000000000000000000000000000..32783f572bb080a2251421a0c35e7e4ce91ac0a7 --- /dev/null +++ b/.run/Run Verifications.run.xml @@ -0,0 +1,25 @@ + + + + + + + + true + true + false + false + + + \ No newline at end of file diff --git a/CHANGE_LOG.md b/CHANGELOG.md similarity index 95% rename from CHANGE_LOG.md rename to CHANGELOG.md index 1d2f025ad3bb378a72dccd335a6228b29dbac03a..15a7061f923572c34624c14879ec344ad97f1338 100644 --- a/CHANGE_LOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ + + +# MybatisX Changelog + +## [Unreleased] + +### Changed + +- Change JVM version to `21` +- Change since build to `251` (2025.1) + # 1.5.4 1. 生成代码时, 选择gradle子模块无效的BUG 2. 修复dtd的支持, 对于www.mybatis.org的DTD进行支持,小鸟可以跳转 diff --git a/README.md b/README.md index 90ecbeb1982d6c767c7161066f9dd3ce1fb00472..6c297a39fe390b16152de251e358bbb19fdcf46d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,16 @@ ## MybatisX idea 快速开发插件 + +MybatisX plugin Features: + +- mapper and xml can jump back and forth +- mybatis.xml,mapper.xml prompt +- mapper and xml support auto prompt like jpa (reference MybatisCodeHelperPro) +- integrate mybatis generator Gui (copy from free mybatis plugin) + +wechat: wx153666 join the group of mybatisx + + # ORM 简化开发 - [Mybatis-Plus Gitee](https://gitee.com/baomidou/mybatis-plus) diff --git a/build.gradle.kts b/build.gradle.kts index 929262f81815d1b8feac633350734e503caf4686..5aa66ee251baaa6c6db604e8be5433828c50a5ad 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,104 +1,170 @@ -//import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType +import org.jetbrains.changelog.Changelog +import org.jetbrains.changelog.markdownToHTML import org.jetbrains.intellij.platform.gradle.TestFrameworkType -// 1.x转2.x的参考 https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html#ids-of-bundled-plugins plugins { -// id("java") // Java support -// alias(libs.plugins.kotlin) apply false // Kotlin support -// alias(libs.plugins.intelliJPlatform) // IntelliJ Platform Gradle Plugin - id("org.jetbrains.intellij.platform") version "2.2.1" -// id("org.jetbrains.intellij.platform.migration") version "2.1.0" - kotlin("jvm") version "1.9.0" + id("java") // Java support + alias(libs.plugins.kotlin) // Kotlin support + alias(libs.plugins.intelliJPlatform) // IntelliJ Platform Gradle Plugin + alias(libs.plugins.changelog) // Gradle Changelog Plugin + alias(libs.plugins.qodana) // Gradle Qodana Plugin + alias(libs.plugins.kover) // Gradle Kover Plugin } -intellijPlatform{ - pluginConfiguration { - ideaVersion { - sinceBuild = "232" - untilBuild = "251.*" - } - } +group = providers.gradleProperty("pluginGroup").get() +version = providers.gradleProperty("pluginVersion").get() + +// Set the JVM language level used to build the project. +kotlin { + jvmToolchain(21) } +// Configure project's dependencies repositories { - mavenLocal() - maven { url=uri("https://maven.aliyun.com/repository/public/") } mavenCentral() + + // IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html intellijPlatform { defaultRepositories() - jetbrainsRuntime() } - maven { url=uri("https://plugins.gradle.org/m2/") } - maven { url=uri("https://oss.sonatype.org/content/repositories/releases/") } - maven { url=uri("https://dl.bintray.com/jetbrains/intellij-plugin-service") } - maven { url=uri("https://dl.bintray.com/jetbrains/intellij-third-party-dependencies/") } - maven("https://maven.aliyun.com/repository/gradle-plugin") - maven {url=uri("https://oss.sonatype.org/content/repositories/snapshots/")} - gradlePluginPortal() } - -// 各种版本去这里找 -// https://www.jetbrains.com/intellij-repository/releases -group = providers.gradleProperty("pluginGroup").get() -version = providers.gradleProperty("pluginVersion").get() - +// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog dependencies { - implementation("com.softwareloop:mybatis-generator-lombok-plugin:1.0") - implementation("uk.com.robust-it:cloning:1.9.2") - implementation("org.mybatis.generator:mybatis-generator-core:1.4.0") - implementation("org.freemarker:freemarker:2.3.30") - implementation("com.itranswarp:compiler:1.0") -// https://mvnrepository.com/artifact/commons-lang/commons-lang - implementation("commons-lang:commons-lang:2.6") + implementation(libs.cloning) + implementation(libs.commons.lang) + implementation(libs.freemarker) + implementation(libs.itranswarp.compiler) + implementation(libs.mybatis.generator.core) + implementation(libs.mybatis.generator.lombok) + compileOnly(libs.lombok) + annotationProcessor(libs.lombok) - testImplementation("junit:junit:4.13.1") - testImplementation("commons-io:commons-io:2.18.0") - compileOnly("org.projectlombok:lombok:1.18.24") - annotationProcessor ("org.projectlombok:lombok:1.18.24") + testImplementation(libs.commons.io) + testImplementation(libs.junit) + // IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html intellijPlatform { - // 依赖版本 https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html#default-target-platforms - intellijIdeaUltimate( providers.gradleProperty("platformVersion"), useInstaller = true) + create(providers.gradleProperty("platformType"), providers.gradleProperty("platformVersion")) + // Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins. bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') }) + // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace. plugins(providers.gradleProperty("platformPlugins").map { it.split(',') }) -// instrumentationTools() - pluginVerifier() - zipSigner() + // Module Dependencies. Uses `platformBundledModules` property from the gradle.properties file for bundled IntelliJ Platform modules. + bundledModules(providers.gradleProperty("platformBundledModules").map { it.split(',') }) + testFramework(TestFrameworkType.Platform) } - compileOnly(libs.intellij.structure.base) { - exclude("org.jetbrains.kotlin") +} + +// Configure IntelliJ Platform Gradle Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html +intellijPlatform { + buildSearchableOptions = false + + pluginConfiguration { + name = providers.gradleProperty("pluginName") + version = providers.gradleProperty("pluginVersion") + + // Extract the section from README.md and provide for the plugin's manifest + description = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map { + val start = "" + val end = "" + + with(it.lines()) { + if (!containsAll(listOf(start, end))) { + throw GradleException("Plugin description section not found in README.md:\n$start ... $end") + } + subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML) + } + } + + val changelog = project.changelog // local variable for configuration cache compatibility + // Get the latest available change notes from the changelog file + changeNotes = providers.gradleProperty("pluginVersion").map { pluginVersion -> + with(changelog) { + renderItem( + (getOrNull(pluginVersion) ?: getUnreleased()) + .withHeader(false) + .withEmptySections(false), + Changelog.OutputType.HTML, + ) + } + } + + ideaVersion { + sinceBuild = providers.gradleProperty("pluginSinceBuild") + } } - compileOnly(libs.intellij.structure.intellij) { - exclude("org.jetbrains.kotlin") - exclude("org.jetbrains.kotlinx") + + signing { + certificateChain = providers.environmentVariable("CERTIFICATE_CHAIN") + privateKey = providers.environmentVariable("PRIVATE_KEY") + password = providers.environmentVariable("PRIVATE_KEY_PASSWORD") + } + + publishing { + token = providers.environmentVariable("PUBLISH_TOKEN") + // The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3 + // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more: + // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel + channels = providers.gradleProperty("pluginVersion").map { listOf(it.substringAfter('-', "").substringBefore('.').ifEmpty { "default" }) } + } + + pluginVerification { + ides { + recommended() + } } -// implementation(libs.annotations) -// implementation(libs.undertow) - -// implementation(libs.intellij.structure.base) { -// exclude("org.jetbrains.kotlin") -// } -// implementation(libs.intellij.structure.intellij) { -// exclude("org.jetbrains.kotlin") -// exclude("org.jetbrains.kotlinx") -// } -// implementation(libs.intellij.pluginRepositoryRestClient) { -// exclude("org.jetbrains.kotlin") -// exclude("org.jetbrains.kotlinx") -// exclude("org.slf4j") -// } } -tasks.withType { - options.encoding = "UTF-8" +// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin +changelog { + groups.empty() + repositoryUrl = providers.gradleProperty("pluginRepositoryUrl") } -tasks.named("buildSearchableOptions").configure { - enabled = false +// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration +kover { + reports { + total { + xml { + onCheck = true + } + } + } +} + +tasks { + wrapper { + gradleVersion = providers.gradleProperty("gradleVersion").get() + } + + publishPlugin { + dependsOn(patchChangelog) + } +} + +intellijPlatformTesting { + runIde { + register("runIdeForUiTests") { + task { + jvmArgumentProviders += CommandLineArgumentProvider { + listOf( + "-Drobot-server.port=8082", + "-Dide.mac.message.dialogs.as.sheets=false", + "-Djb.privacy.policy.text=", + "-Djb.consents.confirmation.enabled=false", + ) + } + } + + plugins { + robotServerPlugin() + } + } + } } diff --git a/gradle.properties b/gradle.properties index d25e017c3f79b36bb50a0e376d057cdc3988467d..b124696e948dfc18df89a80ddd89c04686eea9df 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,26 +1,28 @@ # IntelliJ Platform Artifacts Repositories -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html + pluginGroup = com.baomidou.plugin.idea.mybatisx pluginName = MybatisX -pluginRepositoryUrl = https://github.com/JetBrains/intellij-platform-plugin-template +pluginRepositoryUrl = https://gitee.com/baomidou/MybatisX # SemVer format -> https://semver.org pluginVersion = 1.7.3 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html -pluginSinceBuild = 232 -pluginUntilBuild = 251 +pluginSinceBuild = 251 # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension platformType = IU -platformVersion = 2025.1 +platformVersion = 2025.1.5 # Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html # Example: platformPlugins = com.jetbrains.php:203.4449.22, org.intellij.scala:2023.3.27@EAP platformPlugins = # Example: platformBundledPlugins = com.intellij.java platformBundledPlugins = com.intellij.java,org.jetbrains.kotlin,org.intellij.intelliLang,com.intellij.spring,com.intellij.spring.boot,com.intellij.database +# Example: platformBundledModules = intellij.spellchecker +platformBundledModules = # Gradle Releases -> https://github.com/gradle/gradle/releases -gradleVersion = 8.11 +gradleVersion = 9.0.0 # Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib kotlin.stdlib.default.dependency = false @@ -30,5 +32,3 @@ org.gradle.configuration-cache = true # Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html org.gradle.caching = true - -org.gradle.jvmargs=-Xmx1024m -XX:MaxMetaspaceSize=512m diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index eeb0ce1ea474fae0645453d174d2bffd49e675c5..a36997447b2c1b6cce249d5830c91a4f75f83d4c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,34 +1,36 @@ [versions] # libraries -annotations = "26.0.1" -intellijStructure = "3.287" -intellijPluginRepositoryRestClient = "2.0.39" -kotlinxSerializationJson = "1.6.3" -retrofit = "2.11.0" -undertow = "2.3.18.Final" -xmlutil = "0.86.3" +cloning = "1.9.2" +commons-io = "2.18.0" +commons-lang = "2.6" +freemarker = "2.3.30" +junit = "4.13.1" +itranswarp-compiler = "1.0" +lombok = "1.18.40" +mybatis-generator-core = "1.4.0" +mybatis-generator-lombok = "1.0" # plugins -dokka = "1.9.20" -bcv = "0.16.3" -gradlePluginPublish = "1.3.0" -gradleChangelogPlugin = "2.2.1" +changelog = "2.4.0" +intelliJPlatform = "2.7.2" +kotlin = "2.2.0" +kover = "0.9.1" +qodana = "2025.1.1" [libraries] -annotations = { group = "org.jetbrains", name = "annotations", version.ref = "annotations" } -intellij-pluginRepositoryRestClient = { group = "org.jetbrains.intellij", name = "plugin-repository-rest-client", version.ref = "intellijPluginRepositoryRestClient" } -intellij-structure-base = { group = "org.jetbrains.intellij.plugins", name = "structure-base", version.ref = "intellijStructure" } -intellij-structure-intellij = { group = "org.jetbrains.intellij.plugins", name = "structure-intellij", version.ref = "intellijStructure" } -kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" } -retrofit = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" } -undertow = { group = "io.undertow", name = "undertow-core", version.ref = "undertow" } -xmlutil-core = { group = "io.github.pdvrieze.xmlutil", name = "core-jvm", version.ref = "xmlutil" } -xmlutil-serialization = { group = "io.github.pdvrieze.xmlutil", name = "serialization-jvm", version.ref = "xmlutil" } +cloning = { group = "uk.com.robust-it", name = "cloning", version.ref = "cloning" } +commons-io = { group = "commons-io", name = "commons-io", version.ref = "commons-io" } +commons-lang = { group = "commons-lang", name = "commons-lang", version.ref = "commons-lang" } +freemarker = { group = "org.freemarker", name = "freemarker", version.ref = "freemarker" } +junit = { group = "junit", name = "junit", version.ref = "junit" } +itranswarp-compiler = { group = "com.itranswarp", name = "compiler", version.ref = "itranswarp-compiler" } +lombok = { group = "org.projectlombok", name = "lombok", version.ref = "lombok" } +mybatis-generator-core = { group = "org.mybatis.generator", name = "mybatis-generator-core", version.ref = "mybatis-generator-core" } +mybatis-generator-lombok = { group = "com.softwareloop", name = "mybatis-generator-lombok-plugin", version.ref = "mybatis-generator-lombok" } [plugins] -pluginPublish = { id = "com.gradle.plugin-publish", version.ref = "gradlePluginPublish" } -changelog = { id = "org.jetbrains.changelog", version.ref = "gradleChangelogPlugin" } -dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } -bcv = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "bcv" } -buildLogic = { id = "build-logic", version = "0.0.0" } -#kotlin = {id="kotlin",version="0.0.0"} +changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" } +intelliJPlatform = { id = "org.jetbrains.intellij.platform", version.ref = "intelliJPlatform" } +kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" } +qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index a4b76b9530d66f5e68d973ea569d8e19de379189..8bdaf60c75ab801e22807dde59e12a8735a34077 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 32d3b7285d21af9bf9df1f5ec313faade9bf3518..2a84e188b85a31f9b4c2aa930ce9288fb6dc6936 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,9 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -#distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip -#distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-all.zip -distributionUrl=https\://cache-redirector.jetbrains.com/services.gradle.org/distributions/gradle-8.10.2-all.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip networkTimeout=10000 validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index cdc5fd5374ff447dc33c36aceafb73bac346d186..ef07e0162b183eb9d19a2c9ba7035c283af9f8dd 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,80 +15,115 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$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"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH="\\\"\\\"" + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -97,88 +132,120 @@ Please set the JAVA_HOME variable in your environment to match the 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. + JAVACMD=java + 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" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +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 fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# 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 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" \ + -classpath "$CLASSPATH" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 5093609d512a96947851d39fa2dc05df2af2248e..db3a6ac207e507b0bc1635a9f2c18d3b174e682e 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,8 +13,10 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +27,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +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 @@ -54,49 +57,36 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +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 -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 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 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/qodana.yml b/qodana.yml new file mode 100644 index 0000000000000000000000000000000000000000..81f13b9006ecf61a4ed8518caa9838ccb4b75c74 --- /dev/null +++ b/qodana.yml @@ -0,0 +1,12 @@ +# Qodana configuration: +# https://www.jetbrains.com/help/qodana/qodana-yaml.html + +version: "1.0" +linter: jetbrains/qodana-jvm-community:2024.3 +projectJDK: "21" +profile: + name: qodana.recommended +exclude: + - name: All + paths: + - .qodana diff --git a/settings.gradle.kts b/settings.gradle.kts index 0f782e1f59b132b32ae85fc78ff655eaf5166fa9..f61777505b6fdf5659b631ae9dfaf13f971c06ca 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,4 +1,5 @@ rootProject.name = "MybatisX" + plugins { - id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" + id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" } diff --git a/src/main/java/com/baomidou/plugin/idea/mybatisx/system/refactoring/MapperMethodSafeDeleteProcessor.java b/src/main/java/com/baomidou/plugin/idea/mybatisx/system/refactoring/MapperMethodSafeDeleteProcessor.java index 3e1755b0a9b0bbc6ab45f8e47404892079c9d313..e9b639d1175effc2b362664f79819e5522d830c4 100644 --- a/src/main/java/com/baomidou/plugin/idea/mybatisx/system/refactoring/MapperMethodSafeDeleteProcessor.java +++ b/src/main/java/com/baomidou/plugin/idea/mybatisx/system/refactoring/MapperMethodSafeDeleteProcessor.java @@ -1,102 +1,97 @@ -//package com.baomidou.plugin.idea.mybatisx.system.refactoring; -// -//import com.baomidou.plugin.idea.mybatisx.util.MapperUtils; -//import com.intellij.openapi.module.Module; -//import com.intellij.openapi.project.Project; -//import com.intellij.psi.PsiClass; -//import com.intellij.psi.PsiElement; -//import com.intellij.psi.PsiMethod; -//import com.intellij.psi.xml.XmlTag; -//import com.intellij.refactoring.safeDelete.NonCodeUsageSearchInfo; -//import com.intellij.refactoring.safeDelete.SafeDeleteProcessorDelegateBase; -//import com.intellij.usageView.UsageInfo; -//import com.intellij.util.IncorrectOperationException; -//import org.jetbrains.annotations.NotNull; -//import org.jetbrains.annotations.Nullable; -// -//import java.util.Collection; -//import java.util.List; -// -///** -// * @author : liushang@zsyjr.com -// * @date : 2021/8/11 -// */ -//public class MapperMethodSafeDeleteProcessor extends SafeDeleteProcessorDelegateBase { -// -// -// @Override -// public boolean handlesElement(PsiElement element) { -// // 只处理方法重命名就好了 -// if (!(element instanceof PsiMethod)) { -// return false; -// } -// PsiMethod psiMethod = (PsiMethod) element; -// final PsiClass containingClass = psiMethod.getContainingClass(); -// if (containingClass == null) { -// return false; -// } -// final XmlTag tag = MapperUtils.findTag(containingClass.getProject(), psiMethod); -// return tag != null; -// } -// -// -// @Override -// public void prepareForDeletion(PsiElement element) throws IncorrectOperationException { -// PsiMethod psiMethod = (PsiMethod) element; -// final XmlTag tag = MapperUtils.findTag(psiMethod.getProject(), psiMethod); -// if (tag != null) { -// tag.delete(); -// } -// } -// -// @Override -// public @Nullable -// NonCodeUsageSearchInfo findUsages(@NotNull PsiElement element, @NotNull PsiElement[] allElementsToDelete, @NotNull List result) { -// return null; -// } -// -// @Override -// public @Nullable -// Collection getAdditionalElementsToDelete(@NotNull PsiElement element, @NotNull Collection allElementsToDelete, boolean askUser) { -// return null; -// } -// -// @Override -// public @Nullable -// Collection findConflicts(@NotNull PsiElement element, @NotNull PsiElement[] allElementsToDelete) { -// return null; -// } -// -// @Override -// public @Nullable -// UsageInfo[] preprocessUsages(Project project, UsageInfo[] usages) { -// return usages; -// } -// -// -// @Override -// public boolean isToSearchInComments(PsiElement element) { -// return false; -// } -// -// @Override -// public void setToSearchInComments(PsiElement element, boolean enabled) { -// -// } -// -// @Override -// public boolean isToSearchForTextOccurrences(PsiElement element) { -// return false; -// } -// -// @Override -// public void setToSearchForTextOccurrences(PsiElement element, boolean enabled) { -// -// } -// -// @Override -// public @Nullable -// Collection getElementsToSearch(@NotNull PsiElement element, @Nullable Module module, @NotNull Collection allElementsToDelete) { -// return null; -// } -//} +package com.baomidou.plugin.idea.mybatisx.system.refactoring; + +import com.baomidou.plugin.idea.mybatisx.util.MapperUtils; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.project.Project; +import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiMethod; +import com.intellij.psi.xml.XmlTag; +import com.intellij.refactoring.safeDelete.NonCodeUsageSearchInfo; +import com.intellij.refactoring.safeDelete.SafeDeleteProcessorDelegateBase; +import com.intellij.usageView.UsageInfo; +import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collection; +import java.util.List; + +/** + * @author : liushang@zsyjr.com + * @date : 2021/8/11 + */ +public class MapperMethodSafeDeleteProcessor extends SafeDeleteProcessorDelegateBase { + + + @Override + public boolean handlesElement(PsiElement element) { + // 只处理方法重命名就好了 + if (!(element instanceof PsiMethod)) { + return false; + } + PsiMethod psiMethod = (PsiMethod) element; + final PsiClass containingClass = psiMethod.getContainingClass(); + if (containingClass == null) { + return false; + } + final XmlTag tag = MapperUtils.findTag(containingClass.getProject(), psiMethod); + return tag != null; + } + + + @Override + public void prepareForDeletion(PsiElement element) throws IncorrectOperationException { + PsiMethod psiMethod = (PsiMethod) element; + final XmlTag tag = MapperUtils.findTag(psiMethod.getProject(), psiMethod); + if (tag != null) { + tag.delete(); + } + } + + @Override + public @Nullable NonCodeUsageSearchInfo findUsages(@NotNull PsiElement element, PsiElement @NotNull [] allElementsToDelete, @NotNull List result) { + return null; + } + + @Override + public @Nullable Collection getAdditionalElementsToDelete(@NotNull PsiElement element, @NotNull Collection allElementsToDelete, boolean askUser) { + return null; + } + + @Override + public @Nullable Collection findConflicts(@NotNull PsiElement element, @NotNull PsiElement[] allElementsToDelete) { + return null; + } + + @Override + public @Nullable UsageInfo[] preprocessUsages(Project project, UsageInfo[] usages) { + return usages; + } + + + @Override + public boolean isToSearchInComments(PsiElement element) { + return false; + } + + @Override + public void setToSearchInComments(PsiElement element, boolean enabled) { + + } + + @Override + public boolean isToSearchForTextOccurrences(PsiElement element) { + return false; + } + + @Override + public void setToSearchForTextOccurrences(PsiElement element, boolean enabled) { + + } + + @Override + public @Nullable Collection getElementsToSearch(@NotNull PsiElement element, @Nullable Module module, @NotNull Collection allElementsToDelete) { + return null; + } +} diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 50e32d9681a031699487666f1ccfc0134e47f072..619c175c04df83bebc2775a441241acc2033c9c9 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -1,40 +1,7 @@ com.baomidou.plugin.idea.mybatisx - MyBatisX - MybatisX - - -
  • mapper and xml can jump back and forth
  • -
  • mybatis.xml,mapper.xml prompt
  • -
  • mapper and xml support auto prompt like jpa (reference MybatisCodeHelperPro)
  • -
  • integrate mybatis generator Gui (copy from free mybatis plugin)
  • - - - wechat: wx153666 join the group of mybatisx - ]]> -
    - - 1.4.8 -
      -
    • change style of generate code by templates
    • -
    • fixed some bugs
    • -
    -

    1.3.6

    -
      -
    • fixed some bugs
    • -
    • fixed advance tip for jpa
    • -
    • fixed xml generate for multi module
    • -
    • fixed alias scan for springboot
    • -
    - ]]> -
    - - - + jo bob + com.intellij.java com.intellij.database @@ -84,7 +51,7 @@ - +