Skip to content

Commit

Permalink
chore: update build info for publish package
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 5, 2023
1 parent 3951310 commit a1e70a6
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 14 deletions.
140 changes: 127 additions & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,28 +1,142 @@
plugins {
base
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.serialization)

id("java-library")
id("maven-publish")
publishing
signing

id("jacoco-report-aggregation")
}

group = "org.unitmesh"
version = "1.0-SNAPSHOT"
jacoco {
toolVersion = "0.8.8"
}

repositories {
mavenCentral()
mavenLocal()
google()
}

dependencies {
implementation(libs.javaparser)
implementation(libs.javaparser.serialization)
implementation(libs.javaparser.symbol.solver.core)
allprojects {
apply(plugin = "java")
apply(plugin = "jacoco")

testImplementation(kotlin("test"))
testImplementation(libs.bundles.test)
}
repositories {
mavenCentral()
mavenLocal()
}

group = "cc.unitmesh"
version = "0.1.0-SNAPSHOT"

java.sourceCompatibility = JavaVersion.VERSION_11
java.targetCompatibility = JavaVersion.VERSION_11

tasks.withType<Test> {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}

tasks.test {
finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run
}

tasks.test {
useJUnitPlatform()
tasks.jacocoTestReport {
dependsOn(tasks.test) // tests are required to run before generating the report
}

tasks.jacocoTestReport {
reports {
xml.required.set(true)
csv.required.set(false)
html.outputLocation.set(layout.buildDirectory.dir("jacocoHtml"))
}
}
}

kotlin {
jvmToolchain(11)
configure(allprojects) {
apply(plugin = "java-library")
apply(plugin = "maven-publish")
apply(plugin = "signing")
apply(plugin = "publishing")

publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
}
pom {
name.set("Unit Eval")
description.set("Unit Mesh Eval")
url.set("https://github.com/unit-mesh/")
licenses {
license {
name.set("MIT")
url.set("https://raw.githubusercontent.com/unit-mesh/unit-eval/master/LICENSE")
}
}
licenses {
license {
name.set("MIT")
url.set("https://github.com/unit-mesh/unit-eval/raw/master/LICENSE")
}
}
developers {
developer {
id.set("Unit Mesh")
name.set("UnitMesh Team")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:git://github.com/unit-mesh/unit-eval.git")
developerConnection.set("scm:git:ssh://github.com/unit-mesh/unit-eval.git")
url.set("https://github.com/unit-mesh/unit-eval/")
}
}
}
}

repositories {
maven {
val releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl

credentials {
username = (
if (project.findProperty("sonatypeUsername") != null) project.findProperty("sonatypeUsername") else System.getenv(
"MAVEN_USERNAME"
)).toString()
password = (
if (project.findProperty("sonatypePassword") != null) project.findProperty("sonatypePassword") else System.getenv(
"MAVEN_PASSWORD"
)).toString()
}
}
}
}

signing {
sign(publishing.publications["mavenJava"])
}

java {
withJavadocJar()
withSourcesJar()
}
}

3 changes: 2 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

rootProject.name = "UnitEval"
rootProject.name = "UnitMeshEval"

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0"
Expand All @@ -11,6 +11,7 @@ plugins {
include(
"unit-core",
"unit-picker",
"unit-eval",

"code-quality"
)
47 changes: 47 additions & 0 deletions unit-eval/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.shadow)
alias(libs.plugins.serialization)
application
}

repositories {
mavenCentral()
}

dependencies {
implementation(libs.clikt)
implementation(libs.serialization.json)

// Logging
implementation(libs.logging.slf4j.api)
implementation(libs.logging.logback.classic)

testImplementation(kotlin("test"))

testImplementation(libs.bundles.test)
}

tasks.test {
useJUnitPlatform()
}


application {
mainClass.set("cc.unitmesh.eval.checker.MainKt")
}

tasks {
shadowJar {
manifest {
attributes(Pair("Main-Class", "cc.unitmesh.eval.checker.MainKt"))
}
// minimize()
dependencies {
exclude(dependency("org.junit.jupiter:.*:.*"))
exclude(dependency("org.junit:.*:.*"))
exclude(dependency("junit:.*:.*"))
}
}
}
13 changes: 13 additions & 0 deletions unit-eval/src/main/kotlin/cc/unitmesh/eval/Main.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.unimesh.eval

import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.options.option

class Hello : CliktCommand() {
val name by option(help = "your name")
override fun run() {
echo("Hello, $name!")
}
}

fun main(args: Array<String>) = Hello().main(args)

0 comments on commit a1e70a6

Please sign in to comment.