File size: 4,319 Bytes
3b6a58b
 
 
 
0422ae0
3b6a58b
 
 
 
 
 
bb48f57
3b6a58b
 
 
 
 
 
 
 
 
 
 
 
 
 
66cb305
fbe8350
 
469f43c
66cb305
 
3b6a58b
fbe8350
3b6a58b
469f43c
3b6a58b
 
469f43c
 
3b6a58b
469f43c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3b6a58b
 
66cb305
469f43c
66cb305
3b6a58b
 
 
 
 
 
 
 
 
 
fbe8350
 
 
 
3b6a58b
fbe8350
3b6a58b
 
 
 
 
 
 
 
 
 
 
fbe8350
 
 
3b6a58b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6d037ea
 
 
0422ae0
 
 
6d037ea
 
 
 
 
 
3b6a58b
0422ae0
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
plugins {
    id 'java'
    id 'java-library'
    id 'maven-publish'
    id 'signing'
}

archivesBaseName = 'whispercpp'
group = 'io.github.ggerganov'
version = '1.4.0'


sourceCompatibility = 1.8
targetCompatibility = 1.8

sourceSets {
    main {
        resources {
            srcDirs = ['src/main/resources', 'build/generated/resources/main']
        }
    }
    test {
        runtimeClasspath += files('build/generated/resources/main')
    }
}

tasks.register('copyLibwhisperDynlib', Copy) {
    from '../../build/src'
    include 'libwhisper.dylib'
    into 'build/generated/resources/main'
}

tasks.register('copyLibwhisperSo', Copy) {
    from '../../build/src'
    include 'libwhisper.so'
    into 'build/generated/resources/main'
}

tasks.register('copyWhisperDLL', Copy) {
    from '../../build/bin/Release'
    include 'whisper.dll'
    into 'build/generated/resources/main'
}

tasks.register('copyGGML_BASE_DLL', Copy) {
    from '../../build/bin/Release'
    include 'ggml-base.dll'
    into 'build/generated/resources/main'
}

tasks.register('copyGGML_DLL', Copy) {
    from '../../build/bin/Release'
    include 'ggml.dll'
    into 'build/generated/resources/main'
}

tasks.register('copyGGML_CPU_DLL', Copy) {
    from '../../build/bin/Release'
    include 'ggml-cpu.dll'
    into 'build/generated/resources/main'
}

tasks.register('copyLibs') {
    dependsOn copyLibwhisperDynlib, copyLibwhisperSo, copyWhisperDLL, copyGGML_BASE_DLL, copyGGML_DLL, copyGGML_CPU_DLL
}

test {
    systemProperty 'jna.library.path', project.file('build/generated/resources/main').absolutePath
}

java {
    withSourcesJar()
    withJavadocJar()
}

sourcesJar() {
    dependsOn copyLibs
}

jar {
    dependsOn copyLibs
    exclude '**/whisper_java.exp', '**/whisper_java.lib'
}

javadoc {
    options.addStringOption('Xdoclint:none', '-quiet')
}

tasks.withType(Test) {
    useJUnitPlatform()
}

test.dependsOn copyLibs
processResources.dependsOn copyLibs

dependencies {
    implementation "net.java.dev.jna:jna:5.13.0"
    testImplementation "org.junit.jupiter:junit-jupiter:5.9.2"
    testImplementation "org.assertj:assertj-core:3.24.2"
}

repositories {
    mavenCentral()
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            artifactId = 'whispercpp'
            from components.java
            pom {
                name = 'whispercpp'
                description = "Java JNA bindings for OpenAI's Whisper model, implemented in C/C++"
                url = 'https://github.com/ggerganov/whisper.cpp'
                licenses {
                    license {
                        name = 'MIT licence'
                        url = 'https://raw.githubusercontent.com/ggerganov/whisper.cpp/master/LICENSE'
                    }
                }
                developers {
                    developer {
                        id = 'ggerganov'
                        name = 'Georgi Gerganov'
                        email = '[email protected]'
                    }
                    developer {
                        id = 'nalbion'
                        name = 'Nicholas Albion'
                        email = '[email protected]'
                    }
                }
                scm {
                    connection = 'scm:git:git://github.com/ggerganov/whisper.cpp.git'
                    url = 'https://github.com/ggerganov/whisper.cpp'
                }
            }
        }
    }

    repositories {
        maven {
            def releasesRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
            def snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
            url = version.endsWith('-SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
            credentials {
                username = System.getenv("MAVEN_USERNAME")
                password = System.getenv("MAVEN_PASSWORD")
            }
        }
    }
}

signing {
    def signingKey = System.getenv("PGP_SECRET")
    def signingPassword = System.getenv("PGP_PASSPHRASE")
    useInMemoryPgpKeys(signingKey, signingPassword)
    sign publishing.publications.mavenJava
}