Towdium / PinIn-Old

Java library for Chinese text match using Pinyin - 用于各类汉语拼音匹配问题的 Java 库
MIT License
2 stars 0 forks source link

Consider publishing to maven repo? #1

Closed balthild closed 4 years ago

balthild commented 4 years ago

I'm backporting some functionality of JustEnoughCharacters to NEI in 1.7.10. It might be helpful if the dependency can be referenced from a maven repo, such as the mavenCentral. GitHub Packages is also a good choice.

Towdium commented 4 years ago

It is reasonable, but seems overkill to me. If you are using gradle, you can refer to the build file, which fetches the jar file from github release, set it as dependency and bundle it when compiling. What you really need is:

repositories {
    mavenCentral()
    maven { url = 'http://dvs1.progwml6.com/files/maven' }
    flatDir { dirs 'libs' }
}

configurations {
    fatJar
}

dependencies {
    mkdir 'libs'
    def url = 'https://github.com/Towdium/PinIn/releases/' +
            "download/v${verpinin}/PinIn-${verpinin}.jar"
    ant.get src: url, dest: "libs/PinIn-${verpinin}.jar", skipexisting: true
    implementation name: "PinIn-${verpinin}"
    fatJar name: "PinIn-${verpinin}"
}

clean {
    delete 'libs'
}

jar {
    from {
        configurations.fatJar.collect { it.isDirectory() ? it : zipTree(it) }
    }
}

For 1.7.10, there is a mod called NEI easy search. The matching logic is not so detailed, but it might be good enough for your situation.

Also, PinIn is used for JECh 1.14+ only, there can be issues somewhere. If you have decided to use it, I would suggest to follow the updates to get rid of crashes. For the widely used 1.12 version, it uses internal logic for pinyin matching, which is less powerful but well-tested if you want something easier to maintain.

By the way, as far as I know, NEI uses realtime matching. If it's true, you have to use realtime API provided by PinIn, or implement caching logic specifically for NEI. I have spend a thousand years polishing realtime matching performance, but don't be surprised to see lags if you have thousands of items.

I'm not familiar with Maven. Let me know if none of above solves you issue, then I will try to upload it to Maven.

balthild commented 4 years ago

Currently I'm just shipping the jar with source code, and the workaround that fetching jar in build script seems enough for my project.

NEI easy search uses pinyin4j with some hacky matching mechanisms, which leads to some strange behaviors. And it is not open sourced so I cannot fork it. Therefore, I decided to recreate another mod.

Towdium commented 4 years ago

Good to know it works. I'll find how to upload it later.

Towdium commented 4 years ago

我放弃了,Maven 搞起来贼烦人,Github Package 又智障的很。等 Github Package 支持删除文件再考虑上传吧。目前还是 ant get 凑合一下算了。令人蛋痛(