Added maven publishing info.

This commit is contained in:
Erik C. Thauvin 2021-05-08 02:17:40 -07:00
parent 764baf371d
commit cd76f2d9cb
3 changed files with 215 additions and 1 deletions

View file

@ -1,12 +1,29 @@
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins { plugins {
id("com.github.ben-manes.versions") version "0.38.0" id("com.github.ben-manes.versions") version "0.38.0"
id("io.gitlab.arturbosch.detekt") version "1.17.0-RC1" id("io.gitlab.arturbosch.detekt") version "1.17.0-RC1"
id("org.jetbrains.dokka") version "1.4.32"
id("org.sonarqube") version "3.2.0"
kotlin("jvm") version "1.5.0" kotlin("jvm") version "1.5.0"
application application
`maven-publish`
jacoco
signing
} }
defaultTasks(ApplicationPlugin.TASK_RUN_NAME) defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
description = "Retrieve cryptocurrencies current market prices."
group = "net.thauvin.erik"
version = "0.9.0-SNAPSHOT"
val deployDir = "deploy"
val gitHub = "ethauvin/$name"
val mavenUrl = "https://github.com/$gitHub"
val publicationName = "mavenJava"
repositories { repositories {
mavenCentral() mavenCentral()
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") } maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
@ -27,6 +44,134 @@ application {
mainClassName = "net.thauvin.erik.crypto.CryptoPrice" mainClassName = "net.thauvin.erik.crypto.CryptoPrice"
} }
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withSourcesJar()
}
detekt { detekt {
toolVersion = "main-SNAPSHOT" toolVersion = "main-SNAPSHOT"
} }
sonarqube {
properties {
property("sonar.projectKey", "ethauvin_$name")
property("sonar.sourceEncoding", "UTF-8")
}
}
val javadocJar by tasks.creating(Jar::class) {
dependsOn(tasks.dokkaJavadoc)
from(tasks.dokkaJavadoc)
archiveClassifier.set("javadoc")
}
tasks {
withType<KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = "1.8"
}
withType<GenerateMavenPom> {
destination = file("$projectDir/pom.xml")
}
jacoco {
toolVersion = "0.8.7"
}
jacocoTestReport {
dependsOn(test)
reports {
xml.isEnabled = true
html.isEnabled = true
}
}
clean {
doLast {
project.delete(fileTree(deployDir))
}
}
withType<DokkaTask>().configureEach {
dokkaSourceSets {
named("main") {
moduleName.set("CryptoPrice")
}
}
}
val copyToDeploy by registering(Copy::class) {
from(configurations.runtimeClasspath) {
exclude("annotations-*.jar")
}
from(jar)
into(deployDir)
}
register("deploy") {
description = "Copies all needed files to the $deployDir directory."
group = PublishingPlugin.PUBLISH_TASK_GROUP
dependsOn("build", "jar")
outputs.dir(deployDir)
inputs.files(copyToDeploy)
mustRunAfter("clean")
}
"sonarqube" {
dependsOn("jacocoTestReport")
}
}
publishing {
publications {
create<MavenPublication>(publicationName) {
from(components["java"])
artifact(javadocJar)
pom {
name.set(project.name)
description.set(project.description)
url.set(mavenUrl)
licenses {
license {
name.set("BSD 3-Clause")
url.set("https://opensource.org/licenses/BSD-3-Clause")
}
}
developers {
developer {
id.set("ethauvin")
name.set("Erik C. Thauvin")
email.set("erik@thauvin.net")
url.set("https://erik.thauvin.net/")
}
}
scm {
connection.set("scm:git:git://github.com/$gitHub.git")
developerConnection.set("scm:git:git@github.com:$gitHub.git")
url.set("$mavenUrl")
}
issueManagement {
system.set("GitHub")
url.set("$mavenUrl/issues")
}
}
}
}
repositories {
maven {
name = "ossrh"
url = if (project.version.toString().contains("SNAPSHOT"))
uri("https://oss.sonatype.org/content/repositories/snapshots/") else
uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials(PasswordCredentials::class)
}
}
}
signing {
useGpgCmd()
sign(publishing.publications[publicationName])
}

69
pom.xml Normal file
View file

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- This module was also published with a richer model, Gradle metadata, -->
<!-- which should be used instead. Do not delete the following line which -->
<!-- is to indicate to Gradle or any Gradle module metadata file consumer -->
<!-- that they should prefer consuming it instead. -->
<!-- do_not_remove: published-with-gradle-metadata -->
<modelVersion>4.0.0</modelVersion>
<groupId>net.thauvin.erik</groupId>
<artifactId>cryptoprice</artifactId>
<version>0.9.0-SNAPSHOT</version>
<name>cryptoprice</name>
<description>Retrieve cryptocurrencies current market prices.</description>
<url>https://github.com/ethauvin/cryptoprice</url>
<licenses>
<license>
<name>BSD 3-Clause</name>
<url>https://opensource.org/licenses/BSD-3-Clause</url>
</license>
</licenses>
<developers>
<developer>
<id>ethauvin</id>
<name>Erik C. Thauvin</name>
<email>erik@thauvin.net</email>
<url>https://erik.thauvin.net/</url>
</developer>
</developers>
<scm>
<connection>scm:git:git://github.com/ethauvin/cryptoprice.git</connection>
<developerConnection>scm:git:git@github.com:ethauvin/cryptoprice.git</developerConnection>
<url>https://github.com/ethauvin/cryptoprice</url>
</scm>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/ethauvin/cryptoprice/issues</url>
</issueManagement>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-bom</artifactId>
<version>1.5.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>1.5.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20210307</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>

View file

@ -7,4 +7,4 @@
* in the user manual at https://docs.gradle.org/7.0/userguide/multi_project_builds.html * in the user manual at https://docs.gradle.org/7.0/userguide/multi_project_builds.html
*/ */
rootProject.name = "CryptoPrice" rootProject.name = "cryptoprice"