Skip to content

Commit 24de921

Browse files
authored
Merge pull request #34 from TheProgramSrc/feat/updates-and-sonatype
Sonatype & Updates
2 parents 6572c6a + 4f0a562 commit 24de921

File tree

15 files changed

+232
-156
lines changed

15 files changed

+232
-156
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

.github/workflows/gradle-test.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ jobs:
1212
runs-on: ubuntu-latest
1313
# Set up environment variables
1414
env:
15-
env: 'local' # Set to local, so it won't deploy the jar to the repos
15+
ENV: 'local' # Set to local, so it won't deploy the jar to the repos
1616
steps:
17-
# Checkout code
18-
- name: Checkout Code
19-
uses: actions/checkout@v3
20-
# Setup java and maven
21-
- name: Set up JDK ${{ matrix.java-version }}
22-
uses: actions/setup-java@v3
23-
with:
24-
distribution: adopt
25-
java-version: ${{ matrix.java-version }}
26-
cache: 'gradle'
27-
# Setup executable gradle
28-
- name: Make Gradle executable
29-
run: chmod +x gradlew
30-
# Test building without dokka
31-
- name: Build Jar with Java ${{ matrix.java-version }}
32-
run: ./gradlew clean publish shadow -x dokkaHtml
17+
# Checkout code
18+
- name: Checkout Code
19+
uses: actions/checkout@v3
20+
# Setup java and maven
21+
- name: Set up JDK ${{ matrix.java-version }}
22+
uses: actions/setup-java@v3
23+
with:
24+
distribution: adopt
25+
java-version: ${{ matrix.java-version }}
26+
cache: 'gradle'
27+
# Setup executable gradle
28+
- name: Make Gradle executable
29+
run: chmod +x gradlew
30+
# Test building without dokka
31+
- name: Build Jar with Java ${{ matrix.java-version }}
32+
run: ./gradlew clean shadowJar test -x dokkaHtml -no-daemon

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
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+
* Updated repositories
8+
19
## v0.1.3 - Snapshot
210
* Updated Dependencies
311
* Migrated to JitPack

build.gradle

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

build.gradle.kts

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

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.

0 commit comments

Comments
 (0)