1+ import com.github.breadmoirai.githubreleaseplugin.GithubReleaseTask
2+
3+ group = " com.cjcrafter"
4+ version = " 1.0.0"
5+
6+ plugins {
7+ `java- library`
8+ `maven- publish`
9+ signing
10+ id(" com.github.breadmoirai.github-release" ) version " 2.4.1"
11+ }
12+
13+ repositories {
14+ mavenCentral()
15+ }
16+
17+ dependencies {
18+ implementation(" com.squareup.okhttp3:okhttp:4.9.2" )
19+ implementation(" com.google.code.gson:gson:2.10.1" )
20+ }
21+
22+ java {
23+ toolchain {
24+ languageVersion.set(JavaLanguageVersion .of(17 ))
25+ }
26+ }
27+
28+ tasks {
29+ compileJava {
30+ options.encoding = Charsets .UTF_8 .name() // We want UTF-8 for everything
31+ options.release.set(8 )
32+ }
33+ javadoc {
34+ options.encoding = Charsets .UTF_8 .name() // We want UTF-8 for everything
35+ }
36+ processResources {
37+ filteringCharset = Charsets .UTF_8 .name() // We want UTF-8 for everything
38+ }
39+ }
40+
41+ // Create javadocJar and sourcesJar tasks
42+ val javadocJar by tasks.registering(Jar ::class ) {
43+ archiveClassifier.set(" javadoc" )
44+ from(tasks.named(" javadoc" ))
45+ }
46+
47+ val sourcesJar by tasks.registering(Jar ::class ) {
48+ archiveClassifier.set(" sources" )
49+ from(sourceSets.main.get().allSource)
50+ }
51+
52+ // Signing artifacts
53+ signing {
54+ isRequired = true
55+ // useGpgCmd()
56+
57+ useInMemoryPgpKeys(
58+ findProperty(" SIGNING_KEY_ID" ).toString(),
59+ findProperty(" SIGNING_PRIVATE_KEY" ).toString(),
60+ findProperty(" SIGNING_PASSWORD" ).toString()
61+ )
62+ // sign(configurations["archives"])
63+ sign(publishing.publications)
64+ }
65+
66+ publishing {
67+ publications {
68+ create<MavenPublication >(" mavenJava" ) {
69+ from(components[" java" ])
70+
71+ artifact(javadocJar)
72+ artifact(sourcesJar)
73+
74+ pom {
75+ name.set(" OpenAI Java API" )
76+ description.set(" Access OpenAI's API without the raw JSON/HTTPS requests" )
77+ url.set(" https://github.com/CJCrafter/ChatGPT-Java-API" )
78+
79+ groupId = " com.cjcrafter"
80+ artifactId = " openai"
81+
82+ licenses {
83+ license {
84+ name.set(" The MIT License" )
85+ url.set(" https://opensource.org/licenses/MIT" )
86+ }
87+ }
88+ developers {
89+ developer {
90+ id.set(" CJCrafter" )
91+ name.set(" Collin Barber" )
92+ email.set(" collinjbarber@gmail.com" )
93+ }
94+ }
95+ scm {
96+ connection.set(" scm:git:https://github.com/CJCrafter/ChatGPT-Java-API.git" )
97+ developerConnection.set(" scm:git:ssh://github.com/CJCrafter/ChatGPT-Java-API.git" )
98+ url.set(" https://github.com/CJCrafter/ChatGPT-Java-API" )
99+ }
100+ }
101+ }
102+ }
103+
104+ repositories {
105+ maven {
106+ url = uri(" https://s01.oss.sonatype.org/service/local/staging/deploy/maven2" )
107+ credentials {
108+ username = findProperty(" OSSRH_USERNAME" ).toString()
109+ password = findProperty(" OSSRH_PASSWORD" ).toString()
110+ }
111+ }
112+ }
113+ }
114+
115+ tasks.register<GithubReleaseTask >(" createGithubRelease" ).configure {
116+ // https://github.com/BreadMoirai/github-release-gradle-plugin
117+ owner.set(" CJCrafter" )
118+ repo.set(" ChatGPT-Java-API" )
119+ authorization.set(" Token ${findProperty(" GITHUB_TOKEN" ).toString()} " )
120+ tagName.set(" $version " )
121+ targetCommitish.set(" master" )
122+ releaseName.set(" $version " )
123+ draft.set(false )
124+ prerelease.set(false )
125+ generateReleaseNotes.set(true )
126+ body.set("""
127+ For Gradle projects, add this to your `build.gradle` file in the dependencies block:
128+ ```groovy
129+ dependencies {
130+ implementation 'com.cjcrafter:openai:$version '
131+ }
132+ ```
133+ Or, if you are using Kotlin DSL (`build.gradle.kts`), add this to your dependencies block:
134+ ```kotlin
135+ dependencies {
136+ implementation("com.cjcrafter:openai:$version ")
137+ }
138+ ```
139+ For Maven projects, add this to your `pom.xml` file in the `<dependencies>` block:
140+ ```xml
141+ <dependency>
142+ <groupId>com.cjcrafter</groupId>
143+ <artifactId>openai</artifactId>
144+ <version>$version </version>
145+ </dependency>
146+ ```
147+ See the [maven repository](https://central.sonatype.com/artifact/com.cjcrafter/openai/$version ) for gradle/ant/etc.
148+ """ .trimIndent())
149+ overwrite.set(false )
150+ allowUploadToExisting.set(false )
151+ apiEndpoint.set(" https://api.github.com" )
152+
153+ setReleaseAssets(/* empty */ )
154+
155+ // If set to true, you can debug that this would do
156+ dryRun.set(false )
157+ }
0 commit comments