代码之家  ›  专栏  ›  技术社区  ›  Marko Dumic

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

  •  28
  • Marko Dumic  · 技术社区  · 17 年前

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

    9 回复  |  直到 17 年前
        1
  •  9
  •   Manfred Hantschel    15 年前

    为了摆脱旧的插件,你必须清除安装历史。转到帮助|关于Eclipse |安装详细信息|安装历史记录并选择所有旧内容。然后单击删除并重新启动。瞧。这适用于Eclipse Helios(3.6)

        2
  •  7
  •   Konstantin Kolinko    7 年前

    我使用以下命令:

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

    笔记:

    1. Equinox/p2/FAQ

      常见问题解答参考 an Eclipse Community Forum thread “插件jar在特性卸载后仍然保留”(2010年6月)作为这个配方的来源。

      配方至今仍然有效,Eclipse4.8光子。

    2. 这个 -profile epp.package.jee )是“eclipseforjavaee开发人员”。我在档案里找到的 configuration/config.ini . 相关线路如下:

      eclipse.p2.profile=epp.package.jee
      
        3
  •  6
  •   LiuYan 刘研    13 年前

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

    这个脚本将扫描Eclipse目录下的plugins目录。会产生一个 remove-old-eclipse-plugins.txt 可以用来删除旧插件的文件。

    此脚本在WindowsXP上的Cygwin1.7.15下进行测试。

    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
    

    重要注意事项

    使用生成的 要删除插件,请确保其中列出的所有插件都已删除 真正地 _ 角色。例如:JUnitV3和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
    

    所以, 小心使用

    样本输出

    $ ./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]
    ...
    

    生成的脚本示例

    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
    
        4
  •  6
  •   Community Mohan Dere    5 年前

    Eclipse插件清理程序

    ( 通过测试,由maven&托管在github,所以您可以自由地使用它 )通过自省清单文件(或者如果清单不完整或损坏,则检查文件名)来检查插件的重复性。

    现在

    例如,您可以很容易地下载最新的Eclipse并将旧的Eclipse放入 dropins/eclipse dropins 如果找到两个或多个相同版本,则首选删除文件夹)。

    有关 Eclipse插件清理程序 https://github.com/azachar/eclipse-plugin-cleaner

        5
  •  5
  •   Ogmios    10 年前

    而不是排序等。解决方案应基于 bundles.info

    手动解决方案:

    • 创建的副本 eclipse/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info
    • 搜索正则表达式: .*plugins/([^,]*),.* ,替换为: $1 (例如使用
    • eclipse/plugin/
    • 总指挥 标记>从文件加载所选内容 )
    • 反向选择
    • 删除/移动选定的文件和文件夹
        6
  •  4
  •   Braiam nahurmf    5 年前

    我已经修改了脚本以允许所有dropin、features和plugins。

    接下来,它将限定的插件版本名简化为规范的插件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
    
        7
  •  3
  •   Gionata    6 年前

    对我来说这很有效:

    eclipse -application org.eclipse.equinox.p2.garbagecollector.application -profile SDKProfile
    

    测试了eclipsev4.9。删除旧版本的插件。 个人资料 epp.package.jee

        8
  •  2
  •   VonC    17 年前

    使用Ganymede(3.4),管理插件的正确方法是将它们放到 滴落物

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

    该插件将被“p2”配置机制检测并使用,但是 . 它保存在dropins文件夹中。

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

        9
  •  1
  •   Dónal    17 年前

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

        10
  •  1
  •   Bender270    10 年前

    该脚本有两种操作模式:手动模式询问您如何处理检测到的每个重复插件,而自动模式仅在字符串长度已更改,因此可能已更改系统或版本编号的情况下提出问题。

    # -*- 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()
    
        11
  •  0
  •   Marcel    5 年前

    对于STM32CubeIDE,一个流行的基于Eclipse的用于STM32微控制器系列的IDE,这个命令确实清理了Windows 10下的旧插件版本:

    "C:\ST\STM32CubeIDE_1.3.0\STM32CubeIDE\eclipsec" -application org.eclipse.equinox.p2.garbagecollector.application -profile STM32CubeIDE