IDEA: Compatibility issue when developing with 2021.1.2 IU-2111.7628.21 and the git4idea plugin but work on on 2023.3.2 IU-233.13135.103
Answered
Hello team:
I'm develop a idea plugin work with git,and use lib IDEA 2021.1.2 IU-2111.7628.21 and the git4idea plugin from IDEA 2021.1.2 . Here is the code:
import git4idea.history.GitHistoryUtils;
GitHistoryUtils.loadDeatails(project,gitRepository.getRoot(),gitCommit ->{
//do something
},GitHistoryUtils.formHashParameters(gitRepository.getVcs(),commitIdList))
It work well on IDEA 2021.1.2, but when I use the plugin on 2023.3.2 IU-233.13135.103 I got a exception:
java.lang.NoSuchMethodError: 'java.lang.String[] git4idea.history,GitHistoryUtils.formHashParameters(git4idea.GitVcs,java.util.Collection)'
And I cannot find git4idea.jar on 2023.3.2 plugin folder which can find on 2023.1.2 plugin folder ,I only found vcs-git.jar
.
So how to solve this problem?
Please sign in to leave a comment.
I found Since version 221.5080.210, method
GitHistoryUtils.formHashParameters(GitVcs,Collection<String>hashes)
change toGitHistoryUtils.formHashParameters(Project,Collection<String>hashes)
.So is there any way to implement my code in both versions? Or I need to provide two different version plugin?
You must not use hardcoded .jar files, but refer to bundled plugins as explained here https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html.
If the API signature has changed between two major versions, then the best solution is to have a distinct branch for each target IDE version using its API and setting since/until-build accordingly. https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html#multipleIDEVersions