如何删除旧版本的Eclipse插件?

时间:2021-11-16 00:00:45

After update, old Eclipse plugins remain in "plugins" folder (there are also leftovers in "features" folder).

更新后,旧的Eclipse插件仍保留在“plugins”文件夹中(“features”文件夹中也有剩余部分)。

Is there a way to remove those automatically?

有没有办法自动删除它们?

9 个解决方案

#1


9  

To get rid of the old plugins you have to clear the Installation History. Go to Help | About Eclipse | Installation Details | Installation History and select all the old stuff. Then click delete and restart. Voila. This works with Eclipse Helios (3.6)

要删除旧插件,您必须清除安装历史记录。转到帮助|关于Eclipse |安装细节|安装历史记录并选择所有旧的东西。然后单击删除并重新启动。瞧。这适用于Eclipse Helios(3.6)

#2


5  

I also want to remove old plugins, but still found no answer today, so I wrote a quick and dirty script guess-old-eclipse-plugins.sh to handle old plugins.

我也想删除旧的插件,但今天仍然没有找到答案,所以我写了一个快速而脏的脚本guess-old-eclipse-plugins.sh来处理旧的插件。

This script will scan plugins directory under Eclipse directory. and will generate a remove-old-eclipse-plugins.txt file which can be used to remove old plugins.

该脚本将扫描Eclipse目录下的plugins目录。并将生成一个remove-old-eclipse-plugins.txt文件,该文件可用于删除旧插件。

This script is tested under Cygwin 1.7.15 on Windows XP.

此脚本在Windows XP上的Cygwin 1.7.15下进行了测试。

guess-old-eclipse-plugins.sh

PluginsDir=plugins
FeaturesDir=features
PluginIDSeparator=_
RemovingScriptFileName=remove-old-eclipse-plugins.txt
rm -rf $RemovingScriptFileName

#for dir in $PluginsDir $FeaturesDir
for dir in $PluginsDir  # $FeaturesDir: most file names in features dir contains more than 1 _ character
do
    echo "Processing [$dir] directory..."
    # split PluginID from filename
    # (not reliable, but general working. (ex: will get one junit PluginID because there're move than 1 _ characters in file name))
    file_list=$(ls $dir);
    echo "$file_list" | cut -f1 -d $PluginIDSeparator         > $dir-all.txt
    echo "$file_list" | cut -f1 -d $PluginIDSeparator  | uniq > $dir-uniq.txt

    # get the PluginList which VERY POSSIBLY has old versions
    diff_result=$(diff -U 0 $dir-uniq.txt $dir-all.txt)
    plugins_which_has_old_versions=$(echo "$diff_result" | grep -e "^+[^+]" | cut -f 2 -d +)

    #
    for p in $(echo "$plugins_which_has_old_versions")
    do
        echo "$p"
        i=0
        for f in $(ls -d -t $dir/$p$PluginIDSeparator*) # use 'ls' command, can sort result by file time, but can not handle file name contains special characters (white space) when using wildcard
        #for f in $(find $dir -name "$p$PluginIDSeparator*")    # use 'find' command
        do
            if [ -d $f ]
            then
                # should use rm -rf
                echo -n "[D]"
            else
                echo -n "   "
            fi
            echo -n "$f"

            ((i++))
            if [ $i -eq 1 ]
            then
                echo ""
                continue    # first file, the newest version
            fi
            echo "    [old]"
            echo "rm -rf $f" >> $RemovingScriptFileName
        done

        echo
    done
done

IMPORTANT NOTICE

Before use the generated remove-old-eclipse-plugins.txt file to remove plugins, make sure all the listed plugins in it are REALLY old plugins. Because, this script can't handle file name contains more than 1 _ characters. For example: JUnit v3 and v4 plugins are 2 different plugins, but the script will treat it as same plugins because these 2 file names use same org.junit_ prefix.

在使用生成的remove-old-eclipse-plugins.txt文件删除插件之前,请确保其中列出的所有插件都是真正的旧插件。因为,这个脚本无法处理文件名包含多于1个_字符。例如:JUnit v3和v4插件是2个不同的插件,但脚本会将其视为相同的插件,因为这两个文件名使用相同的org.junit_前缀。

org.junit
[D]plugins/org.junit_3.8.2.v3_8_2_v20100427-1100
[D]plugins/org.junit_4.8.2.v4_8_2_v20110321-1705    [old]  <-- wrong

So, use it VERY CAREFULLY, remove the wrong part before use it, or your Eclipse IDE may not work properly.

因此,非常小心地使用它,在使用它之前删除错误的部分,否则您的Eclipse IDE可能无法正常工作。

Sample output

$ ./guess-old-eclipse-plugins.sh
Processing [plugins] directory...
org.eclipse.gef
   plugins/org.eclipse.gef_3.7.2.v20111106-2020.jar
   plugins/org.eclipse.gef_3.6.2.v20110110-2020.jar    [old]

org.eclipse.help.base
   plugins/org.eclipse.help.base_3.6.2.v201202080800.jar
   plugins/org.eclipse.help.base_3.5.3.v201102101200.jar    [old]

org.eclipse.help.ui
   plugins/org.eclipse.help.ui_3.5.101.r37_20110819.jar
   plugins/org.eclipse.help.ui_3.5.3.r36_20101116.jar    [old]
...

Sample generated script

rm -rf plugins/org.eclipse.gef_3.6.2.v20110110-2020.jar
rm -rf plugins/org.eclipse.help.base_3.5.3.v201102101200.jar
rm -rf plugins/org.eclipse.help.ui_3.5.3.r36_20101116.jar
rm -rf plugins/org.eclipse.help.webapp_3.5.3.r36_20101130.jar
rm -rf plugins/org.eclipse.jdt.apt.core_3.3.402.R36_v20110120-1000.jar
rm -rf plugins/org.eclipse.jdt.debug.ui_3.5.2.v20100928a_r362.jar

#3


5  

Removing old plugins is always a hassle. Especially when you upgrade and your Eclipse just doesn't want to start again and you need to figure it out via the metadata hell of plugins dependencies.

删除旧插件总是很麻烦。特别是当您升级并且您的Eclipse不想再次启动时,您需要通过插件依赖项的元数据来解决它。

I've seen that couple of you tried to fix this via a script.

我见过你们这几个人试图通过脚本解决这个问题。

Eclipse Plugin Cleaner

Well I have created a java based tool (with tests, build by maven & hosted at github, so you are free to fork it) that checks for duplicities of plugins by introspecting manifest files (or file names if the manifest is incomplete or corrupted).

好吧,我已经创建了一个基于java的工具(带有测试,由maven构建并托管在github,所以你可以*分叉),通过内省清单文件(如果清单不完整或已损坏,则检查文件名)来检查插件的重复性。

Now

you can quite easily for example download the latest Eclipse and put your old Eclipse into dropins/eclipse folder and the tool will clean up the dropins folder - thus your new bundles are preserved and old one are deleted (The dropins folder is prefered for deletion if 2 or more same versions are found).

您可以非常轻松地下载最新的Eclipse并将旧的Eclipse放入dropins / eclipse文件夹,该工具将清理dropins文件夹 - 因此您的新包将被保留并且旧的包将被删除(如果删除了dropins文件夹,则优先删除找到2个或更多相同版本)。

More information about the Eclipse Plugin Cleaner can be found at https://github.com/azachar/eclipse-plugin-cleaner

有关Eclipse插件清理程序的更多信息,请访问https://github.com/azachar/eclipse-plugin-cleaner

#4


4  

I've modified the script to allow for all dropins, features, and plugins. First it relies on reverse sort to guess the most recent canonical plugin version.

我修改了脚本以允许所有dropins,功能和插件。首先,它依赖于反向排序来猜测最新的规范插件版本。

Next it reduces that qualified plugin version name to a canonical plugin sed expression. If the plugin is the first match for this expression it stores its pattern and keeps it, otherwise it is an old stale version and it flags it for deletion.

接下来,它将合格的插件版本名称减少为规范插件sed表达式。如果插件是该表达式的第一个匹配项,则它存储其模式并保留它,否则它是一个旧的过时版本,并将其标记为删除。



# scan_old_plugins.sh

# script to scan for duplicate old eclipse features, plugins and dropins
# generates a "clean-old-plugins.sh" script to clean old versions.
# warning: DANGEROUS! review clean-old-plugins script before running it.

DropinsDir=dropins
FeaturesDir=features
PluginsDir=plugins

CanonicalPluginsFile=sed_canonical_plugins.sh
CleanPluginScriptFile=clean_old_plugins.sh

echo "" > $CanonicalPluginsFile
echo "" > $CleanPluginScriptFile

#for dir in $PluginsDir
for dir in $FeaturesDir $PluginsDir $DropinsDir
do
    echo "Processing [$dir] directory..."
    # 
    file_list=$(\ls -1 $dir | sort -r);
    echo "$file_list" > $dir-all.txt

    #
    for p in $(echo "$file_list")
    do
        v=$(echo $p | sed -e 's/_[0-9\._\-]*/_.*/g' | sed -e 's/[0-9][0-9]*/.*/g')
        g=$(grep -l "$v" $CanonicalPluginsFile | head -1 | awk '{print $1}')
        if [ "$g" = "" ]; then
            echo "$p=keep";
            echo "$v=$p" >>  $CanonicalPluginsFile
        else
            echo "$p=stale";
            echo "rm -rf $p" >> $CleanPluginScriptFile
        fi

    done
done

#5


4  

Instead of sorting, etc. the solutions should be based on the contents of bundles.info.

而不是排序等,解决方案应该基于bundles.info的内容。

Manual solution:

  • create a copy of eclipse/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info
  • 创建eclipse / configuration / org.eclipse.equinox.simpleconfigurator / bundles.info的副本

  • edit
  • search for regular expression: .*plugins/([^,]*),.*, replace with: $1 (e.g. using Notepad++)
  • 搜索正则表达式:。* plugins /([^,] *),. *,替换为:$ 1(例如使用Notepad ++)

  • go to eclipse/plugin/
  • 去eclipse /插件/

  • select files and folders listed in this new file (e.g. in Total Commander: Mark > Load Selection From File)
  • 选择此新文件中列出的文件和文件夹(例如,在Total Commander中:标记>从文件加载选择)

  • invert selection
  • delete/move selected files and folders
  • 删除/移动选定的文件和文件夹

#6


2  

With Ganymede (3.4), the correct way to manage your plugins would be to drop them in the 'dropins' folder:

使用Ganymede(3.4),管理插件的正确方法是将它们放在'dropins'文件夹中:

\[eclipse\]/dropins/eclemma1.3.1/eclipse/(plugins|features)

That plugin will be detected by the 'p2' provisioning mechanism and used, but not copied in the plugins and features directories of eclipse. It stays in the dropins folder.

该插件将由'p2'配置机制检测并使用,但不会复制到eclipse的插件和功能目录中。它保留在dropins文件夹中。

When you will drop eclemma1.3.2, all you have to do is delete eclemma1.3.1 from your dropins directory, and that old version is gone.

当您删除eclemma1.3.2时,您所要做的就是从dropins目录中删除eclemma1.3.1,旧版本就不见了。

#7


1  

Eclipse allows you to revert back to any previous configuration (go to the Help menu, then "Software Updates"). My guess is that Eclipse won't remove these old versions, or this functionality would no longer work.

Eclipse允许您恢复到以前的任何配置(转到“帮助”菜单,然后“软件更新”)。我的猜测是Eclipse不会删除这些旧版本,否则此功能将不再起作用。

If when you restart Eclipse you provide the "-clean" argument, it performs various cleanup operations, but for reasons stated above I don't think it will remove old plugins/features.

如果重新启动Eclipse时提供“-clean”参数,它会执行各种清理操作,但由于上述原因,我认为它不会删除旧的插件/功能。

#8


1  

I've created a script in python to move the old plugins to a backup folder, so if something goes wrong it can go back. The script has two modes of operation: Manual mode asks you what to do with each duplicated plugin detected, and automatic only question in cases where the length of the string has changed and therefore may have changed the system, or version numbering.

我已经在python中创建了一个脚本来将旧插件移动到备份文件夹,所以如果出现问题,它可以返回。该脚本有两种操作模式:手动模式询问您如何处理检测到的每个重复插件,并且在字符串长度发生变化的情况下仅自动询问,因此可能更改了系统或版本编号。

I hope this helps someone

我希望这可以帮助别人

# -*- coding: utf-8 -*-
import os
import re
from datetime import datetime

directory="C:\\eclipse64\\plugins"
dirBackup="C:\\eclipse64\\PluginsBackup"        #This folder is a kind of recycle bin for save deleted plugins. In case you have problems running eclipse after remove them you can restore them. If you don't detect any problem you can erase this folder to save disk space
manual=False    #Verifying deletion of each plugin manually (True) or automatic (False) 

def globRegEx(directory,pat,absolutePath=True,type_=0):
    '''Function that given a directory and a regular pattern returns a list of files that meets the pattern

    :param str directory: Base path where we search for files that meet the pattern
    :param str pat: Regular expression that selected files must match 
    :param bool absolutePath: Optional parameter that indicates if the returned list contains absolute (True) or relative paths (False)
    :param int type_: Type of selection 0: selects files and directories 1: only selects files 2: only selects directories
    :return: a list with the paths that meet the regular pattern
    '''
    names=os.listdir(directory)
    pat=re.compile(pat)
    res=[]

    for name in names:
        if pat.match(name):
            path=directory+os.sep+name

            if type_==1 and os.path.isfile(path):
                res.append(path if absolutePath else name)
            elif type_==2 and os.path.isdir(path):
                res.append(path if absolutePath else name)
            elif type_==0:
                res.append(path if absolutePath else name)

    return(res)

def processRepeated(repList):
    ''' this function is responsible for leaving only the newer version of the plugin
    '''

    if repList and len(repList)>1:     #If the plugin is repeated
        repList.sort(reverse=True)
        print("Repeated plugins found:")
        min=len(repList[0])    # If strings haven't got the same length indicates a change in the numeration version system
        max=min
        newer=datetime.fromtimestamp(0)
        sel=0

        for i,path in enumerate(repList):
            lr=len(path)
            modifDate=datetime.fromtimestamp((os.path.getctime(path)))
            if modifDate>newer:     #Keep the last creation date and its index
                newer=modifDate
                sel=i+1

            if lr<min: 
                min=lr
            elif lr>max: 
                max=lr

            print(str(i+1) + " " + modifDate.strftime("%Y-%m-%d") + ": " + path)
        print(" ")

        if manual or min!=max:      #If manual mode is enabled or if there is a string length diference between different version of plugins
            selec=raw_input("Which version do you want to keep?: ["+str(sel)+"] ")
            if selec:
                selec=int(selec)
            else: 
                selec=sel   #Newer is the Default value
        else:
            selec=1


        del(repList[selec-1])      #Delete selected plugin from the list

        for path in repList:  #Move the rest of the list to the backup folder
            print("Deleting: "+ path)
            os.renames(path,os.path.join(dirBackup,os.path.basename(path)))

        print("-------------------------------------\n\n")

def main():

    filePlugins=globRegEx(directory,"^.*$",False,1)      #Creates a list with all the files only
    dirPlugins=globRegEx(directory,"^.*$",False,2)       #Creates a list with all the folders only


    #Process files first

    for plugin in filePlugins:
        m=re.match(r"(.*_)\d.*?\.jar$",plugin)   #Creates the glob pattern
        if m:
            patAux=m.groups()[0]+".*?\.jar$"
            find=globRegEx(directory,patAux,True,1)
            processRepeated(find)

    #Now Directories 

    for plugin in dirPlugins:
        m=re.match(r"(.*_)\d.*$",plugin)   #Creates the glob pattern
        if m:
            patAux=m.groups()[0]+".*$"
            find=globRegEx(directory,patAux,True,2)
            processRepeated(find)

if __name__=="__main__":
    main()

#9


0  

I use the following command:

我使用以下命令:

eclipse -application org.eclipse.equinox.p2.garbagecollector.application -profile epp.package.jee

Notes:

  1. This is documented in Equinox/p2/FAQ, see "Why aren't bundles being removed when their associated feature has been removed?"

    这在Equinox / p2 / FAQ中有记录,请参阅“为什么在删除相关功能后不删除捆绑包?”

    The FAQ answer references an Eclipse Community Forum thread "Plug-in jar remains after feature uninstall" (June 2010) as the origin for this recipe.

    FAQ回答引用了Eclipse社区论坛主题“功能卸载后插件jar”(2010年6月)作为此配方的来源。

    The recipe is still valid nowadays, with Eclipse 4.8 Photon.

    使用Eclipse 4.8 Photon,配方现在仍然有效。

  2. The -profile argument depends on what packaging of Eclipse IDE you are using. The above one (epp.package.jee) is for "Eclipse for Java EE Developers". I found it in the file configuration/config.ini. The relevant line there is the following:

    -profile参数取决于您正在使用的Eclipse IDE的包装。上面的一个(epp.package.jee)是“Eclipse for Java EE Developers”。我在文件configuration / config.ini中找到了它。相关的行有以下内容:

    eclipse.p2.profile=epp.package.jee
    

#1


9  

To get rid of the old plugins you have to clear the Installation History. Go to Help | About Eclipse | Installation Details | Installation History and select all the old stuff. Then click delete and restart. Voila. This works with Eclipse Helios (3.6)

要删除旧插件,您必须清除安装历史记录。转到帮助|关于Eclipse |安装细节|安装历史记录并选择所有旧的东西。然后单击删除并重新启动。瞧。这适用于Eclipse Helios(3.6)

#2


5  

I also want to remove old plugins, but still found no answer today, so I wrote a quick and dirty script guess-old-eclipse-plugins.sh to handle old plugins.

我也想删除旧的插件,但今天仍然没有找到答案,所以我写了一个快速而脏的脚本guess-old-eclipse-plugins.sh来处理旧的插件。

This script will scan plugins directory under Eclipse directory. and will generate a remove-old-eclipse-plugins.txt file which can be used to remove old plugins.

该脚本将扫描Eclipse目录下的plugins目录。并将生成一个remove-old-eclipse-plugins.txt文件,该文件可用于删除旧插件。

This script is tested under Cygwin 1.7.15 on Windows XP.

此脚本在Windows XP上的Cygwin 1.7.15下进行了测试。

guess-old-eclipse-plugins.sh

PluginsDir=plugins
FeaturesDir=features
PluginIDSeparator=_
RemovingScriptFileName=remove-old-eclipse-plugins.txt
rm -rf $RemovingScriptFileName

#for dir in $PluginsDir $FeaturesDir
for dir in $PluginsDir  # $FeaturesDir: most file names in features dir contains more than 1 _ character
do
    echo "Processing [$dir] directory..."
    # split PluginID from filename
    # (not reliable, but general working. (ex: will get one junit PluginID because there're move than 1 _ characters in file name))
    file_list=$(ls $dir);
    echo "$file_list" | cut -f1 -d $PluginIDSeparator         > $dir-all.txt
    echo "$file_list" | cut -f1 -d $PluginIDSeparator  | uniq > $dir-uniq.txt

    # get the PluginList which VERY POSSIBLY has old versions
    diff_result=$(diff -U 0 $dir-uniq.txt $dir-all.txt)
    plugins_which_has_old_versions=$(echo "$diff_result" | grep -e "^+[^+]" | cut -f 2 -d +)

    #
    for p in $(echo "$plugins_which_has_old_versions")
    do
        echo "$p"
        i=0
        for f in $(ls -d -t $dir/$p$PluginIDSeparator*) # use 'ls' command, can sort result by file time, but can not handle file name contains special characters (white space) when using wildcard
        #for f in $(find $dir -name "$p$PluginIDSeparator*")    # use 'find' command
        do
            if [ -d $f ]
            then
                # should use rm -rf
                echo -n "[D]"
            else
                echo -n "   "
            fi
            echo -n "$f"

            ((i++))
            if [ $i -eq 1 ]
            then
                echo ""
                continue    # first file, the newest version
            fi
            echo "    [old]"
            echo "rm -rf $f" >> $RemovingScriptFileName
        done

        echo
    done
done

IMPORTANT NOTICE

Before use the generated remove-old-eclipse-plugins.txt file to remove plugins, make sure all the listed plugins in it are REALLY old plugins. Because, this script can't handle file name contains more than 1 _ characters. For example: JUnit v3 and v4 plugins are 2 different plugins, but the script will treat it as same plugins because these 2 file names use same org.junit_ prefix.

在使用生成的remove-old-eclipse-plugins.txt文件删除插件之前,请确保其中列出的所有插件都是真正的旧插件。因为,这个脚本无法处理文件名包含多于1个_字符。例如:JUnit v3和v4插件是2个不同的插件,但脚本会将其视为相同的插件,因为这两个文件名使用相同的org.junit_前缀。

org.junit
[D]plugins/org.junit_3.8.2.v3_8_2_v20100427-1100
[D]plugins/org.junit_4.8.2.v4_8_2_v20110321-1705    [old]  <-- wrong

So, use it VERY CAREFULLY, remove the wrong part before use it, or your Eclipse IDE may not work properly.

因此,非常小心地使用它,在使用它之前删除错误的部分,否则您的Eclipse IDE可能无法正常工作。

Sample output

$ ./guess-old-eclipse-plugins.sh
Processing [plugins] directory...
org.eclipse.gef
   plugins/org.eclipse.gef_3.7.2.v20111106-2020.jar
   plugins/org.eclipse.gef_3.6.2.v20110110-2020.jar    [old]

org.eclipse.help.base
   plugins/org.eclipse.help.base_3.6.2.v201202080800.jar
   plugins/org.eclipse.help.base_3.5.3.v201102101200.jar    [old]

org.eclipse.help.ui
   plugins/org.eclipse.help.ui_3.5.101.r37_20110819.jar
   plugins/org.eclipse.help.ui_3.5.3.r36_20101116.jar    [old]
...

Sample generated script

rm -rf plugins/org.eclipse.gef_3.6.2.v20110110-2020.jar
rm -rf plugins/org.eclipse.help.base_3.5.3.v201102101200.jar
rm -rf plugins/org.eclipse.help.ui_3.5.3.r36_20101116.jar
rm -rf plugins/org.eclipse.help.webapp_3.5.3.r36_20101130.jar
rm -rf plugins/org.eclipse.jdt.apt.core_3.3.402.R36_v20110120-1000.jar
rm -rf plugins/org.eclipse.jdt.debug.ui_3.5.2.v20100928a_r362.jar

#3


5  

Removing old plugins is always a hassle. Especially when you upgrade and your Eclipse just doesn't want to start again and you need to figure it out via the metadata hell of plugins dependencies.

删除旧插件总是很麻烦。特别是当您升级并且您的Eclipse不想再次启动时,您需要通过插件依赖项的元数据来解决它。

I've seen that couple of you tried to fix this via a script.

我见过你们这几个人试图通过脚本解决这个问题。

Eclipse Plugin Cleaner

Well I have created a java based tool (with tests, build by maven & hosted at github, so you are free to fork it) that checks for duplicities of plugins by introspecting manifest files (or file names if the manifest is incomplete or corrupted).

好吧,我已经创建了一个基于java的工具(带有测试,由maven构建并托管在github,所以你可以*分叉),通过内省清单文件(如果清单不完整或已损坏,则检查文件名)来检查插件的重复性。

Now

you can quite easily for example download the latest Eclipse and put your old Eclipse into dropins/eclipse folder and the tool will clean up the dropins folder - thus your new bundles are preserved and old one are deleted (The dropins folder is prefered for deletion if 2 or more same versions are found).

您可以非常轻松地下载最新的Eclipse并将旧的Eclipse放入dropins / eclipse文件夹,该工具将清理dropins文件夹 - 因此您的新包将被保留并且旧的包将被删除(如果删除了dropins文件夹,则优先删除找到2个或更多相同版本)。

More information about the Eclipse Plugin Cleaner can be found at https://github.com/azachar/eclipse-plugin-cleaner

有关Eclipse插件清理程序的更多信息,请访问https://github.com/azachar/eclipse-plugin-cleaner

#4


4  

I've modified the script to allow for all dropins, features, and plugins. First it relies on reverse sort to guess the most recent canonical plugin version.

我修改了脚本以允许所有dropins,功能和插件。首先,它依赖于反向排序来猜测最新的规范插件版本。

Next it reduces that qualified plugin version name to a canonical plugin sed expression. If the plugin is the first match for this expression it stores its pattern and keeps it, otherwise it is an old stale version and it flags it for deletion.

接下来,它将合格的插件版本名称减少为规范插件sed表达式。如果插件是该表达式的第一个匹配项,则它存储其模式并保留它,否则它是一个旧的过时版本,并将其标记为删除。



# scan_old_plugins.sh

# script to scan for duplicate old eclipse features, plugins and dropins
# generates a "clean-old-plugins.sh" script to clean old versions.
# warning: DANGEROUS! review clean-old-plugins script before running it.

DropinsDir=dropins
FeaturesDir=features
PluginsDir=plugins

CanonicalPluginsFile=sed_canonical_plugins.sh
CleanPluginScriptFile=clean_old_plugins.sh

echo "" > $CanonicalPluginsFile
echo "" > $CleanPluginScriptFile

#for dir in $PluginsDir
for dir in $FeaturesDir $PluginsDir $DropinsDir
do
    echo "Processing [$dir] directory..."
    # 
    file_list=$(\ls -1 $dir | sort -r);
    echo "$file_list" > $dir-all.txt

    #
    for p in $(echo "$file_list")
    do
        v=$(echo $p | sed -e 's/_[0-9\._\-]*/_.*/g' | sed -e 's/[0-9][0-9]*/.*/g')
        g=$(grep -l "$v" $CanonicalPluginsFile | head -1 | awk '{print $1}')
        if [ "$g" = "" ]; then
            echo "$p=keep";
            echo "$v=$p" >>  $CanonicalPluginsFile
        else
            echo "$p=stale";
            echo "rm -rf $p" >> $CleanPluginScriptFile
        fi

    done
done

#5


4  

Instead of sorting, etc. the solutions should be based on the contents of bundles.info.

而不是排序等,解决方案应该基于bundles.info的内容。

Manual solution:

  • create a copy of eclipse/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info
  • 创建eclipse / configuration / org.eclipse.equinox.simpleconfigurator / bundles.info的副本

  • edit
  • search for regular expression: .*plugins/([^,]*),.*, replace with: $1 (e.g. using Notepad++)
  • 搜索正则表达式:。* plugins /([^,] *),. *,替换为:$ 1(例如使用Notepad ++)

  • go to eclipse/plugin/
  • 去eclipse /插件/

  • select files and folders listed in this new file (e.g. in Total Commander: Mark > Load Selection From File)
  • 选择此新文件中列出的文件和文件夹(例如,在Total Commander中:标记>从文件加载选择)

  • invert selection
  • delete/move selected files and folders
  • 删除/移动选定的文件和文件夹

#6


2  

With Ganymede (3.4), the correct way to manage your plugins would be to drop them in the 'dropins' folder:

使用Ganymede(3.4),管理插件的正确方法是将它们放在'dropins'文件夹中:

\[eclipse\]/dropins/eclemma1.3.1/eclipse/(plugins|features)

That plugin will be detected by the 'p2' provisioning mechanism and used, but not copied in the plugins and features directories of eclipse. It stays in the dropins folder.

该插件将由'p2'配置机制检测并使用,但不会复制到eclipse的插件和功能目录中。它保留在dropins文件夹中。

When you will drop eclemma1.3.2, all you have to do is delete eclemma1.3.1 from your dropins directory, and that old version is gone.

当您删除eclemma1.3.2时,您所要做的就是从dropins目录中删除eclemma1.3.1,旧版本就不见了。

#7


1  

Eclipse allows you to revert back to any previous configuration (go to the Help menu, then "Software Updates"). My guess is that Eclipse won't remove these old versions, or this functionality would no longer work.

Eclipse允许您恢复到以前的任何配置(转到“帮助”菜单,然后“软件更新”)。我的猜测是Eclipse不会删除这些旧版本,否则此功能将不再起作用。

If when you restart Eclipse you provide the "-clean" argument, it performs various cleanup operations, but for reasons stated above I don't think it will remove old plugins/features.

如果重新启动Eclipse时提供“-clean”参数,它会执行各种清理操作,但由于上述原因,我认为它不会删除旧的插件/功能。

#8


1  

I've created a script in python to move the old plugins to a backup folder, so if something goes wrong it can go back. The script has two modes of operation: Manual mode asks you what to do with each duplicated plugin detected, and automatic only question in cases where the length of the string has changed and therefore may have changed the system, or version numbering.

我已经在python中创建了一个脚本来将旧插件移动到备份文件夹,所以如果出现问题,它可以返回。该脚本有两种操作模式:手动模式询问您如何处理检测到的每个重复插件,并且在字符串长度发生变化的情况下仅自动询问,因此可能更改了系统或版本编号。

I hope this helps someone

我希望这可以帮助别人

# -*- coding: utf-8 -*-
import os
import re
from datetime import datetime

directory="C:\\eclipse64\\plugins"
dirBackup="C:\\eclipse64\\PluginsBackup"        #This folder is a kind of recycle bin for save deleted plugins. In case you have problems running eclipse after remove them you can restore them. If you don't detect any problem you can erase this folder to save disk space
manual=False    #Verifying deletion of each plugin manually (True) or automatic (False) 

def globRegEx(directory,pat,absolutePath=True,type_=0):
    '''Function that given a directory and a regular pattern returns a list of files that meets the pattern

    :param str directory: Base path where we search for files that meet the pattern
    :param str pat: Regular expression that selected files must match 
    :param bool absolutePath: Optional parameter that indicates if the returned list contains absolute (True) or relative paths (False)
    :param int type_: Type of selection 0: selects files and directories 1: only selects files 2: only selects directories
    :return: a list with the paths that meet the regular pattern
    '''
    names=os.listdir(directory)
    pat=re.compile(pat)
    res=[]

    for name in names:
        if pat.match(name):
            path=directory+os.sep+name

            if type_==1 and os.path.isfile(path):
                res.append(path if absolutePath else name)
            elif type_==2 and os.path.isdir(path):
                res.append(path if absolutePath else name)
            elif type_==0:
                res.append(path if absolutePath else name)

    return(res)

def processRepeated(repList):
    ''' this function is responsible for leaving only the newer version of the plugin
    '''

    if repList and len(repList)>1:     #If the plugin is repeated
        repList.sort(reverse=True)
        print("Repeated plugins found:")
        min=len(repList[0])    # If strings haven't got the same length indicates a change in the numeration version system
        max=min
        newer=datetime.fromtimestamp(0)
        sel=0

        for i,path in enumerate(repList):
            lr=len(path)
            modifDate=datetime.fromtimestamp((os.path.getctime(path)))
            if modifDate>newer:     #Keep the last creation date and its index
                newer=modifDate
                sel=i+1

            if lr<min: 
                min=lr
            elif lr>max: 
                max=lr

            print(str(i+1) + " " + modifDate.strftime("%Y-%m-%d") + ": " + path)
        print(" ")

        if manual or min!=max:      #If manual mode is enabled or if there is a string length diference between different version of plugins
            selec=raw_input("Which version do you want to keep?: ["+str(sel)+"] ")
            if selec:
                selec=int(selec)
            else: 
                selec=sel   #Newer is the Default value
        else:
            selec=1


        del(repList[selec-1])      #Delete selected plugin from the list

        for path in repList:  #Move the rest of the list to the backup folder
            print("Deleting: "+ path)
            os.renames(path,os.path.join(dirBackup,os.path.basename(path)))

        print("-------------------------------------\n\n")

def main():

    filePlugins=globRegEx(directory,"^.*$",False,1)      #Creates a list with all the files only
    dirPlugins=globRegEx(directory,"^.*$",False,2)       #Creates a list with all the folders only


    #Process files first

    for plugin in filePlugins:
        m=re.match(r"(.*_)\d.*?\.jar$",plugin)   #Creates the glob pattern
        if m:
            patAux=m.groups()[0]+".*?\.jar$"
            find=globRegEx(directory,patAux,True,1)
            processRepeated(find)

    #Now Directories 

    for plugin in dirPlugins:
        m=re.match(r"(.*_)\d.*$",plugin)   #Creates the glob pattern
        if m:
            patAux=m.groups()[0]+".*$"
            find=globRegEx(directory,patAux,True,2)
            processRepeated(find)

if __name__=="__main__":
    main()

#9


0  

I use the following command:

我使用以下命令:

eclipse -application org.eclipse.equinox.p2.garbagecollector.application -profile epp.package.jee

Notes:

  1. This is documented in Equinox/p2/FAQ, see "Why aren't bundles being removed when their associated feature has been removed?"

    这在Equinox / p2 / FAQ中有记录,请参阅“为什么在删除相关功能后不删除捆绑包?”

    The FAQ answer references an Eclipse Community Forum thread "Plug-in jar remains after feature uninstall" (June 2010) as the origin for this recipe.

    FAQ回答引用了Eclipse社区论坛主题“功能卸载后插件jar”(2010年6月)作为此配方的来源。

    The recipe is still valid nowadays, with Eclipse 4.8 Photon.

    使用Eclipse 4.8 Photon,配方现在仍然有效。

  2. The -profile argument depends on what packaging of Eclipse IDE you are using. The above one (epp.package.jee) is for "Eclipse for Java EE Developers". I found it in the file configuration/config.ini. The relevant line there is the following:

    -profile参数取决于您正在使用的Eclipse IDE的包装。上面的一个(epp.package.jee)是“Eclipse for Java EE Developers”。我在文件configuration / config.ini中找到了它。相关的行有以下内容:

    eclipse.p2.profile=epp.package.jee