es ctags for code on win

setup

# dep: tar, 7z, pwsh, java

$theGrokRoot="D:/sevtest/opengrok"

$theTomcatRoot="D:/sevtest/tomcat"

$theGrokFile="./opengrok-1.12.11.tar.gz"
$theTomcatFile="./apache-tomcat-10.1.8.tar.gz"

#===============================================================================
# make root
#===============================================================================
New-Item -Path @($theGrokRoot,$theTomcatRoot) -ItemType Directory

#===============================================================================
# extract grok
#===============================================================================
cd $theGrokRoot

New-Item -Path @('src','data','dist','etc','log') -ItemType Directory

cd -

tar -C $theGrokRoot/dist --strip-components=1 -xzf $theGrokFile


#===============================================================================
# copy log property
#===============================================================================
Copy-Item -Path $theGrokRoot/dist/doc/logging.properties $theGrokRoot/etc/logging.properties


#===============================================================================
# extract Tomcat
#===============================================================================
tar -C $theTomcatRoot/ --strip-components=1 -xzf $theTomcatFile

#===============================================================================
# extract web page source
#===============================================================================
$webAppSource=$theTomcatRoot+"/webapps/source"

New-Item -Path @($webAppSource) -ItemType Directory

$inputSource=$theGrokRoot + "/dist/lib/source.war"
$sourceExtractPathOption="-o" + $webAppSource
7z x $inputSource $sourceExtractPathOption


#===============================================================================
# edit web.xml
#===============================================================================
$webConfig=$theTomcatRoot + "/webapps/source/WEB-INF/web.xml"
$fromString="/var/opengrok/etc/configuration.xml"
$toString=$theGrokRoot + "/etc/configuration.xml"
(Get-Content $webConfig).replace($fromString, $toString) | Set-Content $webConfig

Get-Content $theTomcatRoot/webapps/source/WEB-INF/web.xml

start tom

$theTomcatRoot="D:/sevtest/tomcat"


$env:CATALINA_HOME=$theTomcatRoot
$tomcatStartFile=$theTomcatRoot+"/bin/startup.bat"
echo $tomcatStartFile

cmd.exe -/c $tomcatStartFile

create index

https://github.com/universal-ctags/ctags-win32/releases

$theGrokRoot="D:\sevtest\opengrok"

# universal ctags.exe is in current directory

$CurrentDirectory = Get-Location
$CurrentDirectoryString=Convert-Path -LiteralPath $CurrentDirectory
$absRootToUniversalCtags=$CurrentDirectoryString + "\ctags"


cmd.exe -/c java -jar $theGrokRoot\dist\lib\opengrok.jar -c $absRootToUniversalCtags -s $theGrokRoot\src -d $theGrokRoot\data -P -S -G -W $theGrokRoot\etc\configuration.xml

shut tom

$theTomcatRoot="D:/sevtest/tomcat"


$env:CATALINA_HOME=$theTomcatRoot
$tomcatShutdownFile=$theTomcatRoot+"/bin/shutdown.bat"
echo $tomcatShutdownFile

cmd.exe -/c $tomcatShutdownFile

127.0.0.1:8080/source

pitfall

missing configuration.xml

create index, the file will be created

window junction

mklink 

| /j   | Creates a Directory Junction. |

cmd /c mklink c:\path\to\symlink c:\target\file

cmd /c mklink /j D:\the\symbol\boost181 F:\the\real\file\boost-1.81.0

https://superuser.com/questions/343074/directory-junction-vs-directory-symbolic-link

suggester bug

https://github.com/oracle/opengrok/wiki/Suggester

The ChronicleMap dependency does not work out of the box with Java 9+; as a result, promoting terms based on the previous searches won't work. 
To solve this issue, following parameters are needed to add to java invocation:

--add-exports java.base/jdk.internal.ref=ALL-UNNAMED
--add-exports java.base/jdk.internal.misc=ALL-UNNAMED
--add-exports java.base/sun.nio.ch=ALL-UNNAMED

\opengrok-master\suggester\src\main\java\org\opengrok\suggest\SuggesterProjectData.java

            if (allowMostPopular) {
                initSearchCountMap();
            }

private void initSearchCountMap() throws IOException {
...
            ChronicleMapAdapter m;
            try {
                m = new ChronicleMapAdapter(field, conf.getAverageKeySize(), conf.getEntries(), f);
            } catch (IllegalArgumentException e) {
                logger.log(Level.SEVERE, "Could not create ChronicleMap for field " + field + " in directory "
                        + suggesterDir + " due to invalid key size ("
                        + conf.getAverageKeySize() + ") or number of entries: (" + conf.getEntries() + "):", e);
                return;
            } catch (Throwable t) {
                logger.log(Level.SEVERE,
                        "Could not create ChronicleMap for field " + field + " in directory "
                                + suggesterDir + " , most popular completion disabled, if you are using "
                                + "JDK9+ make sure to specify: "
                                + "--add-exports java.base/jdk.internal.ref=ALL-UNNAMED "
                                + "--add-exports java.base/jdk.internal.misc=ALL-UNNAMED "
                                + "--add-exports java.base/sun.nio.ch=ALL-UNNAMED", t);
                return;
            }

final solution: change opengrok\etc\configuration.xml to close allowMostPopular

  <void id="SuggesterConfig0" property="suggesterConfig">
     <void property="allowMostPopular">
      <boolean>false</boolean>
     </void>

pwsh to do this:

$theGrokRoot="D:/sevtest/opengrok"
$grokConfig=$theGrokRoot + "/etc/configuration.xml"

$fromString='<void id="SuggesterConfig0" property="suggesterConfig">'
$toString = '<void id="SuggesterConfig0" property="suggesterConfig"> <void property="allowMostPopular"> <boolean>false</boolean> </void>'


(Get-Content $grokConfig).replace($fromString, $toString) | Set-Content $grokConfig

powershell sucks!

posted @ 2023-06-21 16:02  fndefbwefsowpvqfx  阅读(18)  评论(0编辑  收藏  举报