-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Adrian Tosca
committed
May 17, 2024
1 parent
92039b3
commit 80ce5b2
Showing
12 changed files
with
199 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,15 +2,19 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL | |
import org.gradle.api.tasks.testing.logging.TestLogEvent.* | ||
|
||
plugins { | ||
`java-library` | ||
alias(libs.plugins.kotlinJvm) | ||
alias(libs.plugins.spotless) | ||
jacoco | ||
alias(libs.plugins.jmh) | ||
`maven-publish` | ||
alias(libs.plugins.jreleaser) | ||
alias(libs.plugins.dokka) | ||
} | ||
|
||
group = "earth.adi" | ||
|
||
version = "0.0.3" | ||
version = "0.0.4" | ||
|
||
repositories { mavenCentral() } | ||
|
||
|
@@ -25,7 +29,10 @@ dependencies { | |
|
||
kotlin { jvmToolchain(17) } | ||
|
||
java { withSourcesJar() } | ||
java { | ||
withSourcesJar() | ||
withJavadocJar() | ||
} | ||
|
||
tasks.withType<JavaCompile> { dependsOn(tasks.spotlessApply) } | ||
|
||
|
@@ -45,6 +52,11 @@ configure<com.diffplug.gradle.spotless.SpotlessExtension> { | |
} | ||
} | ||
|
||
task<Exec>("updateReadmeVersion") { | ||
// mustRunAfter(tasks.build) | ||
commandLine("sh", "./scripts/updateReadmeVersion.sh") | ||
} | ||
|
||
tasks.test { | ||
useJUnitPlatform() | ||
finalizedBy(tasks.jacocoTestReport, tasks.jacocoTestCoverageVerification) | ||
|
@@ -82,7 +94,7 @@ tasks.jacocoTestReport { dependsOn(tasks.test) } | |
tasks.jacocoTestCoverageVerification { | ||
dependsOn(tasks.jacocoTestReport) | ||
|
||
violationRules { rule { limit { minimum = "1".toBigDecimal() } } } | ||
violationRules { rule { limit { minimum = "1.00".toBigDecimal() } } } | ||
} | ||
|
||
jmh { | ||
|
@@ -91,3 +103,81 @@ jmh { | |
threads.set(1) | ||
fork.set(2) | ||
} | ||
|
||
val mavenArtifactId: String by project | ||
val mavenArtifactDescription: String by project | ||
|
||
tasks.jar { | ||
manifest { | ||
attributes( | ||
mapOf( | ||
"Implementation-Title" to mavenArtifactId, "Implementation-Version" to project.version)) | ||
} | ||
} | ||
|
||
val stagingDir: Provider<Directory> = layout.buildDirectory.dir("staging-deploy") | ||
|
||
publishing { | ||
publications { | ||
create<MavenPublication>("mavenJava") { | ||
artifactId = mavenArtifactId | ||
from(components["java"]) | ||
pom { | ||
name.set(mavenArtifactId) | ||
description.set(mavenArtifactDescription) | ||
url.set("https://github.com/aleris/typeid-kotlin") | ||
licenses { | ||
license { | ||
name.set("The Apache License, Version 2.0") | ||
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") | ||
} | ||
} | ||
developers { | ||
developer { | ||
id.set("aleris") | ||
name.set("Adrian Tosca") | ||
email.set("[email protected]") | ||
} | ||
} | ||
scm { | ||
connection.set("scm:git:[email protected]:aleris/typeid-kotlin.git") | ||
developerConnection.set("scm:git:[email protected]:aleris/typeid-kotlin.git") | ||
url.set("https://github.com/aleris/typeid-kotlin/") | ||
} | ||
} | ||
} | ||
} | ||
repositories { maven { url = stagingDir.get().asFile.toURI() } } | ||
} | ||
|
||
tasks.publish { dependsOn(tasks.dokkaJekyll) } | ||
|
||
jreleaser { | ||
project { | ||
description.set(mavenArtifactDescription) | ||
authors.set(arrayListOf("aleris")) | ||
license.set("Apache-2.0") | ||
inceptionYear = "2024" | ||
} | ||
release { | ||
github { | ||
repoOwner.set("aleris") | ||
overwrite = true | ||
} | ||
} | ||
signing { | ||
active.set(org.jreleaser.model.Active.ALWAYS) | ||
armored = true | ||
} | ||
deploy { | ||
maven { | ||
mavenCentral { | ||
register("sonatype") { | ||
active.set(org.jreleaser.model.Active.ALWAYS) | ||
url.set("https://central.sonatype.com/api/v1/publisher") | ||
stagingRepository(stagingDir.get().toString()) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
kotlin.code.style=official | ||
mavenArtifactId=typeid-kotlin | ||
mavenArtifactDescription=A type-safe TypeID implementation for Kotlin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/sh | ||
|
||
# Replace the version in README.md with the version from build.gradle.kts | ||
# Usage: | ||
# ./scripts/updateReadmeVersion.sh | ||
|
||
SED="sed" | ||
if ! command -v gsed &> /dev/null | ||
then | ||
# brew install gnu-sed | ||
SED="gsed" | ||
fi | ||
|
||
VERSION=$(SED -n 's/^version\s*=\s*"\([0-9]\.[0-9]\.[0-9]\)"/\1/p' < build.gradle.kts) | ||
|
||
echo "Updating to version $VERSION in README.md..." | ||
SED -i -E 's/earth\.adi:typeid-kotlin:[0-9]+\.[0-9]+\.[0-9]+/earth\.adi:typeid-kotlin:'"${VERSION}"'/' README.md | ||
SED -i -E 's|<version>[0-9]+\.[0-9]+\.[0-9]+|<version>'"${VERSION}"'|' README.md | ||
SED -i -E 's/Version-[0-9]+\.[0-9]+\.[0-9]+-blue/Version-'"${VERSION}"'-blue/' README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package earth.adi; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package earth.adi.typeid; | ||
|
||
/** | ||
* JavaType. | ||
*/ | ||
public class JavaType { | ||
public static JavaType of(Class<?> clazz) { | ||
return new JavaType(clazz); | ||
} | ||
|
||
private final Class<?> clazz; | ||
|
||
private JavaType(Class<?> clazz) { | ||
this.clazz = clazz; | ||
} | ||
|
||
public Class<?> getClazz() { | ||
return clazz; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
* TypeID package. | ||
*/ | ||
package earth.adi.typeid; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package earth; |
3 changes: 3 additions & 0 deletions
3
src/main/kotlin/module-info.java → src/main/java/module-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package earth.adi.typeid | ||
|
||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.Test | ||
|
||
internal class JavaTypeTest { | ||
@Test | ||
fun of() { | ||
val javaType = JavaType.of(String::class.java) | ||
assertThat(javaType.clazz).isEqualTo(String::class.java) | ||
} | ||
|
||
@Test | ||
fun get() { | ||
val javaType = JavaType.of(String::class.java) | ||
assertThat(javaType.clazz).isEqualTo(String::class.java) | ||
} | ||
} |