| import org.gradle.api.tasks.bundling.AbstractArchiveTask |
| import java.security.MessageDigest |
|
|
| plugins { |
| `java-library` |
| `maven-publish` |
| signing |
| } |
|
|
| group = "org.ortho32" |
| version = "0.1.0" |
|
|
| subprojects { |
| apply(plugin = "java-library") |
| apply(plugin = "maven-publish") |
| apply(plugin = "signing") |
|
|
| group = rootProject.group |
| version = rootProject.version |
|
|
| java { |
| toolchain { |
| languageVersion.set(JavaLanguageVersion.of(21)) |
| } |
| withSourcesJar() |
| withJavadocJar() |
| } |
|
|
| tasks.withType<JavaCompile> { |
| options.encoding = "UTF-8" |
| options.release.set(21) |
| } |
|
|
| tasks.withType<Javadoc> { |
| options.encoding = "UTF-8" |
| } |
|
|
| tasks.withType<AbstractArchiveTask> { |
| isPreserveFileTimestamps = false |
| isReproducibleFileOrder = true |
| dirPermissions { unix("0755") } |
| filePermissions { unix("0644") } |
| } |
|
|
| tasks.withType<Jar> { |
| manifest { |
| attributes( |
| "Implementation-Title" to project.name, |
| "Implementation-Version" to project.version, |
| "Implementation-Vendor" to "ORTHO-32" |
| ) |
| } |
| } |
|
|
| repositories { |
| mavenCentral() |
| } |
|
|
| |
| dependencies { |
| "testImplementation"(platform("org.junit:junit-bom:5.11.0")) |
| "testImplementation"("org.junit.jupiter:junit-jupiter") |
| "testRuntimeOnly"("org.junit.platform:junit-platform-launcher") |
| } |
|
|
| tasks.test { |
| useJUnitPlatform() |
| testLogging { events("passed", "skipped", "failed") } |
| } |
|
|
| publishing { |
| publications { |
| create<MavenPublication>("maven") { |
| from(components["java"]) |
| pom { |
| name.set("ORTHO-32 ${project.name}") |
| description.set("ORTHO-32 Java SDK - ${project.name}") |
| url.set("https://github.com/ortho32/ortho32-sdk-java") |
| licenses { |
| license { |
| name.set("Apache-2.0") |
| url.set("https://www.apache.org/licenses/LICENSE-2.0") |
| } |
| } |
| } |
| } |
| } |
| } |
|
|
| |
| tasks.register("generateChecksums") { |
| group = "verification" |
| description = "Generate SHA-256 checksums for all JAR artifacts" |
| dependsOn(tasks.named("build")) |
| doLast { |
| val digest = MessageDigest.getInstance("SHA-256") |
| fileTree(layout.buildDirectory.dir("libs")).forEach { file -> |
| if (file.isFile && file.extension == "jar") { |
| val hash = digest.digest(file.readBytes()).joinToString("") { "%02x".format(it) } |
| val checksumFile = file.resolveSibling("${file.name}.sha256") |
| checksumFile.writeText("$hash ${file.name}\n") |
| } |
| } |
| } |
| } |
| tasks.named("build") { finalizedBy("generateChecksums") } |
|
|
| |
| dependencyLocking { |
| lockAllConfigurations() |
| } |
| } |
|
|