Skip to content

Commit 7e4cf2a

Browse files
committed
Sonatype & Updates
* Added to sonatype * Updated Dependencies * Updated to gradle 8 * Updated to kotlin 1.8 * Updated to use gradle kotlin dsl Signed-off-by: Francisco Solis <imfran@duck.com>
1 parent 6572c6a commit 7e4cf2a

File tree

14 files changed

+215
-139
lines changed

14 files changed

+215
-139
lines changed

.github/workflows/gradle-build.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ jobs:
77
# Set up the OS
88
runs-on: ubuntu-latest
99
env:
10-
# Nexus credentials and GitHub token
11-
NEXUS_USERNAME: '${{ secrets.NEXUS_USERNAME }}'
12-
NEXUS_PASSWORD: '${{ secrets.NEXUS_PASSWORD }}'
10+
# Sonatype Credentials & GitHub token
11+
SONATYPE_USERNAME: '${{ secrets.SONATYPE_USERNAME }}'
12+
SONATYPE_PASSWORD: '${{ secrets.SONATYPE_PASSWORD }}'
1313
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
1414
# Set environment
15-
env: 'prod'
15+
ENV: 'prod'
1616
steps:
1717
# Checkout the Code
1818
- name: Checkout Code
@@ -37,7 +37,7 @@ jobs:
3737
run: chmod +x gradlew
3838
# Clean, Test, Publish and Build (in that order to save the artifact to the action)
3939
- name: Test, Deploy and Build with Gradle
40-
run: ./gradlew clean test publish shadow dokkaHtml
40+
run: ./gradlew clean test shadowJar dokkaHtml publish publishToSonatype closeAndReleaseSonatypeStagingRepository -no-daemon
4141
# Now we store the artifact in the action
4242
- name: Upload the artifact
4343
uses: actions/upload-artifact@v3
@@ -56,3 +56,5 @@ jobs:
5656
branch: gh-pages
5757
folder: build/dokka
5858
clean: true
59+
clean-exclude: |
60+
CNAME

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## v0.2.0 - Snapshot
2+
* Added to sonatype
3+
* Updated Dependencies
4+
* Updated to gradle 8
5+
* Updated to kotlin 1.8
6+
* Updated to use gradle kotlin dsl
7+
18
## v0.1.3 - Snapshot
29
* Updated Dependencies
310
* Migrated to JitPack

build.gradle

Lines changed: 0 additions & 120 deletions
This file was deleted.

build.gradle.kts

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
import com.github.jengelman.gradle.plugins.shadow.ShadowExtension
2+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
3+
4+
plugins {
5+
`maven-publish`
6+
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
7+
id("com.github.johnrengelman.shadow") version "7.1.2"
8+
id("cl.franciscosolis.blossom-extended") version "1.3.1"
9+
10+
kotlin("jvm") version "1.8.10"
11+
id("org.jetbrains.dokka") version "1.7.20"
12+
}
13+
14+
val env = project.rootProject.file(".env").let { file ->
15+
if(file.exists()) file.readLines().filter { it.isNotBlank() && !it.startsWith("#") && it.split("=").size == 2 }.associate { it.split("=")[0] to it.split("=")[1] } else emptyMap()
16+
}.toMutableMap().apply { putAll(System.getenv()) }
17+
18+
val projectVersion = env["VERSION"] ?: "0.2.0-SNAPSHOT"
19+
20+
group = "xyz.theprogramsrc"
21+
version = projectVersion
22+
description = "File configurations and utils for the SimpleCore API"
23+
24+
repositories {
25+
mavenLocal()
26+
mavenCentral()
27+
28+
maven("https://oss.sonatype.org/content/repositories/snapshots/")
29+
maven("https://oss.sonatype.org/content/repositories/releases/")
30+
maven("https://oss.sonatype.org/content/groups/public/")
31+
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
32+
maven("https://repo.codemc.org/repository/maven-public/")
33+
maven("https://jitpack.io/")
34+
}
35+
36+
dependencies {
37+
compileOnly("xyz.theprogramsrc:simplecoreapi:0.6.2-SNAPSHOT")
38+
39+
implementation("me.carleslc.Simple-YAML:Simple-Yaml:1.8.3")
40+
41+
testImplementation("org.junit.jupiter:junit-jupiter:5.9.2")
42+
}
43+
44+
45+
tasks {
46+
named<ShadowJar>("shadowJar") {
47+
relocate("org.simpleyaml", "xyz.theprogramsrc.filesmodule.libs.simpleyaml")
48+
relocate("org.yaml.snakeyaml", "xyz.theprogramsrc.filesmodule.libs.snakeyaml")
49+
50+
mergeServiceFiles()
51+
exclude("**/*.kotlin_metadata")
52+
exclude("**/*.kotlin_builtins")
53+
54+
archiveBaseName.set("FilesModule")
55+
archiveClassifier.set("")
56+
}
57+
58+
test {
59+
useJUnitPlatform()
60+
}
61+
62+
java {
63+
sourceCompatibility = JavaVersion.VERSION_11
64+
targetCompatibility = JavaVersion.VERSION_11
65+
withSourcesJar()
66+
withJavadocJar()
67+
}
68+
69+
compileKotlin {
70+
kotlinOptions {
71+
jvmTarget = "11"
72+
}
73+
}
74+
75+
compileTestKotlin {
76+
kotlinOptions {
77+
jvmTarget = "11"
78+
}
79+
}
80+
81+
compileJava {
82+
options.encoding = "UTF-8"
83+
}
84+
85+
jar {
86+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
87+
}
88+
89+
copy {
90+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
91+
}
92+
93+
dokkaHtml {
94+
outputDirectory.set(file(project.buildDir.absolutePath + "/dokka"))
95+
}
96+
}
97+
98+
configurations {
99+
testImplementation {
100+
extendsFrom(configurations.compileOnly.get())
101+
}
102+
}
103+
104+
val dokkaJavadocJar by tasks.register<Jar>("dokkaJavadocJar") {
105+
dependsOn(tasks.dokkaJavadoc, tasks.dokkaHtml)
106+
from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
107+
archiveClassifier.set("javadoc")
108+
}
109+
110+
publishing {
111+
repositories {
112+
if (env["ENV"] == "prod") {
113+
if (env.containsKey("GITHUB_ACTOR") && env.containsKey("GITHUB_TOKEN")) {
114+
maven {
115+
name = "GithubPackages"
116+
url = uri("https://maven.pkg.github.com/TheProgramSrc/SimpleCore-FilesModule")
117+
credentials {
118+
username = env["GITHUB_ACTOR"]
119+
password = env["GITHUB_TOKEN"]
120+
}
121+
}
122+
}
123+
} else {
124+
mavenLocal()
125+
}
126+
}
127+
128+
publications {
129+
create<MavenPublication>("shadow") {
130+
project.extensions.configure<ShadowExtension> {
131+
artifactId = rootProject.name.lowercase()
132+
133+
component(this@create)
134+
artifact(dokkaJavadocJar)
135+
artifact(tasks.kotlinSourcesJar)
136+
137+
pom {
138+
name.set(rootProject.name)
139+
description.set(project.description)
140+
url.set("https://github.com/TheProgramSrc/SimpleCore-FilesModule")
141+
142+
licenses {
143+
license {
144+
name.set("GNU GPL v3")
145+
url.set("https://github.com/TheProgramSrc/SimpleCore-FilesModule/blob/master/LICENSE")
146+
}
147+
}
148+
149+
developers {
150+
developer {
151+
id.set("ImFran")
152+
name.set("Francisco Solis")
153+
email.set("imfran@duck.com")
154+
}
155+
}
156+
157+
scm {
158+
url.set("https://github.com/TheProgramSrc/SimpleCore-FilesModule")
159+
}
160+
}
161+
}
162+
}
163+
}
164+
}
165+
166+
nexusPublishing {
167+
repositories {
168+
sonatype {
169+
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
170+
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
171+
172+
username.set(env["SONATYPE_USERNAME"])
173+
password.set(env["SONATYPE_PASSWORD"])
174+
}
175+
}
176+
}
177+
178+
tasks.withType<PublishToMavenRepository> {
179+
dependsOn(tasks.test, tasks.kotlinSourcesJar, dokkaJavadocJar, tasks.jar, tasks.shadowJar)
180+
}
181+
182+
tasks.withType<PublishToMavenLocal> {
183+
dependsOn(tasks.test, tasks.kotlinSourcesJar, tasks.jar, dokkaJavadocJar, tasks.shadowJar)
184+
}

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m

gradle/wrapper/gradle-wrapper.jar

852 Bytes
Binary file not shown.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
4+
networkTimeout=10000
45
zipStoreBase=GRADLE_USER_HOME
56
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)