Skip to content

Commit 41632aa

Browse files
committed
feat(gradle): add missing Maven POM configuration, smarter GitHub release tag getting, and use project name starting from an upper-case letter
1 parent b2371b6 commit 41632aa

2 files changed

Lines changed: 40 additions & 24 deletions

File tree

build.gradle.kts

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
val javaVersion = 25
1010

1111
group = "net.hypejet"
12-
version = System.getenv("GITHUB_REF_NAME") ?: "1.0-SNAPSHOT"
12+
version = releaseTag() ?: "1.0-SNAPSHOT"
1313
description = "A Java library making modular programming easier"
1414

1515
repositories {
@@ -48,40 +48,56 @@ tasks {
4848
publishing {
4949
publications.create<MavenPublication>("maven") {
5050
from(components["java"])
51-
}
52-
}
5351

54-
mavenPublishing {
55-
publishToMavenCentral()
56-
signAllPublications()
52+
pom {
53+
artifactId = project.name.lowercase()
5754

58-
pom {
59-
url = "https://github.com/Hypejet/Modules"
55+
name = project.name
56+
description = project.description
57+
url = "https://github.com/Hypejet/Modules"
6058

61-
licenses {
62-
license {
63-
name = "The Apache License, Version 2.0"
64-
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
59+
licenses {
60+
license {
61+
name = "The Apache License, Version 2.0"
62+
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
63+
}
6564
}
66-
}
6765

68-
developers {
69-
developer {
70-
id = "Codestech1"
71-
name = "Codestech"
72-
email = "codestech@hypejet.net"
66+
developers {
67+
developer {
68+
id = "Codestech1"
69+
name = "Codestech"
70+
email = "codestech@hypejet.net"
71+
}
7372
}
74-
}
7573

76-
scm {
77-
connection = "scm:git:git://github.com/Hypejet/Modules.git"
78-
developerConnection = "scm:git:ssh://github.com:Hypejet/Modules.git"
79-
url = "https://github.com/Hypejet/Modules"
74+
scm {
75+
connection = "scm:git:git://github.com/Hypejet/Modules.git"
76+
developerConnection = "scm:git:ssh://github.com:Hypejet/Modules.git"
77+
url = "https://github.com/Hypejet/Modules"
78+
}
8079
}
8180
}
8281
}
8382

83+
mavenPublishing {
84+
publishToMavenCentral()
85+
signAllPublications()
86+
}
87+
8488
indraSpotlessLicenser {
8589
licenseHeaderFile(rootProject.file("LICENSE_HEADER"))
8690
property("YEAR", Year.now().value.toString())
91+
}
92+
93+
private fun releaseTag(): String? {
94+
val ref = System.getenv("GITHUB_REF") ?: return null
95+
val tagRefPrefix = "refs/tags/"
96+
97+
if (!ref.startsWith(tagRefPrefix))
98+
return null
99+
100+
val tag = ref.removePrefix(tagRefPrefix)
101+
if (tag.isEmpty() || !tag.startsWith("v")) return null
102+
return tag.removePrefix("v").ifEmpty { null }
87103
}

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rootProject.name = "modules"
1+
rootProject.name = "Modules"

0 commit comments

Comments
 (0)