Dependencies and syntax updates.
This commit is contained in:
parent
bca09bbfce
commit
ba4cc22f25
1 changed files with 105 additions and 120 deletions
225
build.gradle.kts
225
build.gradle.kts
|
@ -1,28 +1,23 @@
|
||||||
import com.jfrog.bintray.gradle.BintrayExtension
|
|
||||||
import com.jfrog.bintray.gradle.tasks.BintrayUploadTask
|
import com.jfrog.bintray.gradle.tasks.BintrayUploadTask
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
import org.gradle.api.publish.maven.MavenPom
|
|
||||||
import org.jetbrains.dokka.DokkaConfiguration
|
|
||||||
import org.jetbrains.dokka.gradle.DokkaTask
|
|
||||||
import org.jetbrains.dokka.gradle.LinkMapping
|
import org.jetbrains.dokka.gradle.LinkMapping
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
import java.net.URL
|
|
||||||
import java.util.Properties
|
import java.util.Properties
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.2.50"
|
kotlin("jvm") version "1.3.21"
|
||||||
`build-scan`
|
`build-scan`
|
||||||
java
|
java
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
id("com.github.ben-manes.versions") version "0.20.0"
|
id("com.github.ben-manes.versions") version "0.21.0"
|
||||||
id("com.jfrog.bintray") version "1.8.3"
|
id("com.jfrog.bintray") version "1.8.4"
|
||||||
id("org.jetbrains.dokka") version "0.9.17"
|
id("org.jetbrains.dokka") version "0.9.17"
|
||||||
id("org.jlleitschuh.gradle.ktlint") version "4.1.0"
|
id("org.jlleitschuh.gradle.ktlint") version "7.2.1"
|
||||||
id("io.gitlab.arturbosch.detekt") version "1.0.0.RC7"
|
id("io.gitlab.arturbosch.detekt") version "1.0.0-RC14"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "net.thauvin.erik"
|
group = "net.thauvin.erik"
|
||||||
version = "1.0.0"
|
version = "1.0.1-beta"
|
||||||
description = "Pinboard Poster for Kotlin/Java"
|
description = "Pinboard Poster for Kotlin/Java"
|
||||||
|
|
||||||
val gitHub = "ethauvin/$name"
|
val gitHub = "ethauvin/$name"
|
||||||
|
@ -30,6 +25,8 @@ val mavenUrl = "https://github.com/$gitHub"
|
||||||
val deployDir = "deploy"
|
val deployDir = "deploy"
|
||||||
var isRelease = "release" in gradle.startParameter.taskNames
|
var isRelease = "release" in gradle.startParameter.taskNames
|
||||||
|
|
||||||
|
val publicationName = "mavenJava"
|
||||||
|
|
||||||
// Load local.properties
|
// Load local.properties
|
||||||
File("local.properties").apply {
|
File("local.properties").apply {
|
||||||
if (exists()) {
|
if (exists()) {
|
||||||
|
@ -50,19 +47,27 @@ repositories {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(kotlin("stdlib"))
|
compile(kotlin("stdlib"))
|
||||||
compile("com.squareup.okhttp3:okhttp:3.10.0")
|
compile("com.squareup.okhttp3:okhttp:3.14.0")
|
||||||
testCompile("org.testng:testng:6.14.3")
|
testCompile("org.testng:testng:6.14.3")
|
||||||
}
|
}
|
||||||
|
|
||||||
detekt {
|
detekt {
|
||||||
profile("main", Action {
|
input = files("src/main/kotlin")
|
||||||
//config = "default-detekt-config.yml"
|
filters = ".*/resources/.*,.*/build/.*"
|
||||||
input = "src/main/kotlin"
|
baseline = project.rootDir.resolve("detekt-baseline.xml")
|
||||||
filters = ".*/resources/.*,.*/build/.*"
|
}
|
||||||
output = "$buildDir/reports/detekt-reports"
|
|
||||||
outputName = "detekt-report"
|
val sourcesJar by tasks.creating(Jar::class) {
|
||||||
baseline = "detekt-baseline.xml"
|
archiveClassifier.set("sources")
|
||||||
})
|
from(sourceSets.getByName("main").allSource)
|
||||||
|
}
|
||||||
|
|
||||||
|
val javadocJar by tasks.creating(Jar::class) {
|
||||||
|
dependsOn(tasks.dokka)
|
||||||
|
from(tasks.dokka)
|
||||||
|
archiveClassifier.set("javadoc")
|
||||||
|
description = "Assembles a JAR of the generated Javadoc."
|
||||||
|
group = JavaBasePlugin.DOCUMENTATION_GROUP
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
@ -74,49 +79,34 @@ tasks {
|
||||||
kotlinOptions.jvmTarget = "1.8"
|
kotlinOptions.jvmTarget = "1.8"
|
||||||
}
|
}
|
||||||
|
|
||||||
val sourcesJar by creating(Jar::class) {
|
withType<GenerateMavenPom> {
|
||||||
classifier = "sources"
|
destination = file("$projectDir/pom.xml")
|
||||||
from(java.sourceSets["main"].allSource)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val dokka by getting(DokkaTask::class) {
|
dokka {
|
||||||
dependsOn(java.sourceSets["main"].classesTaskName)
|
|
||||||
outputFormat = "html"
|
outputFormat = "html"
|
||||||
outputDirectory = "$buildDir/javadoc"
|
outputDirectory = "$buildDir/javadoc"
|
||||||
// See https://github.com/Kotlin/dokka/issues/196
|
jdkVersion = 8
|
||||||
externalDocumentationLink(delegateClosureOf<DokkaConfiguration.ExternalDocumentationLink.Builder> {
|
|
||||||
url = URL("https://docs.oracle.com/javase/8/docs/api/")
|
|
||||||
packageListUrl = URL("https://docs.oracle.com/javase/8/docs/api/package-list")
|
|
||||||
})
|
|
||||||
val mapping = LinkMapping().apply {
|
val mapping = LinkMapping().apply {
|
||||||
dir = project.rootDir.toPath().resolve("src/main/kotlin").toFile().path
|
dir = project.rootDir.toPath().resolve("src/main/kotlin").toFile().path
|
||||||
url = "https://github.com/ethauvin/pinboard-poster/blob/${project.version}/src/main/kotlin"
|
url = "https://github.com/ethauvin/pinboard-poster/blob/${project.version}/src/main/kotlin"
|
||||||
suffix = "#L"
|
suffix = "#L"
|
||||||
}
|
}
|
||||||
linkMappings = arrayListOf(mapping)
|
linkMappings = arrayListOf(mapping)
|
||||||
|
|
||||||
includeNonPublic = false
|
includeNonPublic = false
|
||||||
}
|
}
|
||||||
|
|
||||||
val javadocJar by creating(Jar::class) {
|
|
||||||
dependsOn(dokka)
|
|
||||||
from(dokka.outputDirectory)
|
|
||||||
classifier = "javadoc"
|
|
||||||
description = "Assembles a JAR of the generated Javadoc"
|
|
||||||
group = JavaBasePlugin.DOCUMENTATION_GROUP
|
|
||||||
}
|
|
||||||
|
|
||||||
"assemble" {
|
"assemble" {
|
||||||
dependsOn(sourcesJar, javadocJar)
|
dependsOn(sourcesJar, javadocJar)
|
||||||
}
|
}
|
||||||
|
|
||||||
val copyToDeploy by creating(Copy::class) {
|
val copyToDeploy by registering(Copy::class) {
|
||||||
from(configurations.runtime)
|
from(configurations.runtime)
|
||||||
from(tasks["jar"])
|
from(jar)
|
||||||
into(deployDir)
|
into(deployDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
"deploy" {
|
register("deploy") {
|
||||||
description = "Copies all needed files to the $deployDir directory."
|
description = "Copies all needed files to the $deployDir directory."
|
||||||
group = PublishingPlugin.PUBLISH_TASK_GROUP
|
group = PublishingPlugin.PUBLISH_TASK_GROUP
|
||||||
dependsOn("build")
|
dependsOn("build")
|
||||||
|
@ -125,13 +115,13 @@ tasks {
|
||||||
mustRunAfter("clean")
|
mustRunAfter("clean")
|
||||||
}
|
}
|
||||||
|
|
||||||
val gitIsDirty by creating(Exec::class) {
|
val gitIsDirty by registering(Exec::class) {
|
||||||
description = "Fails if git has uncommitted changes."
|
description = "Fails if git has uncommitted changes."
|
||||||
group = "verification"
|
group = "verification"
|
||||||
commandLine("git", "diff", "--quiet", "--exit-code")
|
commandLine("git", "diff", "--quiet", "--exit-code")
|
||||||
}
|
}
|
||||||
|
|
||||||
val gitTag by creating(Exec::class) {
|
val gitTag by registering(Exec::class) {
|
||||||
description = "Tags the local repository with version ${project.version}"
|
description = "Tags the local repository with version ${project.version}"
|
||||||
group = PublishingPlugin.PUBLISH_TASK_GROUP
|
group = PublishingPlugin.PUBLISH_TASK_GROUP
|
||||||
dependsOn(gitIsDirty)
|
dependsOn(gitIsDirty)
|
||||||
|
@ -140,84 +130,12 @@ tasks {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val check by getting {
|
"check" {
|
||||||
dependsOn("ktlintCheck")
|
dependsOn("ktlintCheck")
|
||||||
}
|
}
|
||||||
|
|
||||||
val publicationName = "mavenJava"
|
val bintrayUpload by existing(BintrayUploadTask::class) {
|
||||||
publishing {
|
dependsOn(publishToMavenLocal, gitTag)
|
||||||
(publications) {
|
|
||||||
publicationName(MavenPublication::class) {
|
|
||||||
from(components["java"])
|
|
||||||
artifact(sourcesJar)
|
|
||||||
artifact(javadocJar)
|
|
||||||
pom.withXml {
|
|
||||||
asNode().apply {
|
|
||||||
appendNode("name", project.name)
|
|
||||||
appendNode("description", project.description)
|
|
||||||
appendNode("url", mavenUrl)
|
|
||||||
|
|
||||||
appendNode("licenses").appendNode("license").apply {
|
|
||||||
appendNode("name", "BSD 3-Clause")
|
|
||||||
appendNode("url", "https://opensource.org/licenses/BSD-3-Clause")
|
|
||||||
}
|
|
||||||
|
|
||||||
appendNode("developers").appendNode("developer").apply {
|
|
||||||
appendNode("id", "ethauvin")
|
|
||||||
appendNode("name", "Erik C. Thauvin")
|
|
||||||
appendNode("email", "erik@thauvin.net")
|
|
||||||
}
|
|
||||||
|
|
||||||
appendNode("scm").apply {
|
|
||||||
appendNode("connection", "scm:git:$mavenUrl.git")
|
|
||||||
appendNode("developerConnection", "scm:git:git@github.com:$gitHub.git")
|
|
||||||
appendNode("url", mavenUrl)
|
|
||||||
}
|
|
||||||
|
|
||||||
appendNode("issueManagement").apply {
|
|
||||||
appendNode("system", "GitHub")
|
|
||||||
appendNode("url", "$mavenUrl/issues")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val generatePomFileForMavenJavaPublication by getting(GenerateMavenPom::class) {
|
|
||||||
destination = file("$projectDir/pom.xml")
|
|
||||||
}
|
|
||||||
|
|
||||||
val bintrayUpload by getting(BintrayUploadTask::class) {
|
|
||||||
dependsOn(generatePomFileForMavenJavaPublication, gitTag)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun findProperty(s: String) = project.findProperty(s) as String?
|
|
||||||
bintray {
|
|
||||||
user = findProperty("bintray.user")
|
|
||||||
key = findProperty("bintray.apikey")
|
|
||||||
publish = isRelease
|
|
||||||
setPublications(publicationName)
|
|
||||||
pkg.apply {
|
|
||||||
repo = "maven"
|
|
||||||
name = project.name
|
|
||||||
desc = description
|
|
||||||
websiteUrl = mavenUrl
|
|
||||||
issueTrackerUrl = "$mavenUrl/issues"
|
|
||||||
githubRepo = gitHub
|
|
||||||
githubReleaseNotesFile = "README.md"
|
|
||||||
vcsUrl = "$mavenUrl.git"
|
|
||||||
setLabels("kotlin", "java", "pinboard", "poster", "bookmarks")
|
|
||||||
publicDownloadNumbers = true
|
|
||||||
version.apply {
|
|
||||||
name = project.version as String
|
|
||||||
desc = description
|
|
||||||
vcsTag = project.version as String
|
|
||||||
gpg.apply {
|
|
||||||
sign = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buildScan {
|
buildScan {
|
||||||
|
@ -225,9 +143,76 @@ tasks {
|
||||||
setTermsOfServiceAgree("yes")
|
setTermsOfServiceAgree("yes")
|
||||||
}
|
}
|
||||||
|
|
||||||
"release" {
|
register("release") {
|
||||||
description = "Publishes version ${project.version} to Bintray."
|
description = "Publishes version ${project.version} to Bintray."
|
||||||
group = PublishingPlugin.PUBLISH_TASK_GROUP
|
group = PublishingPlugin.PUBLISH_TASK_GROUP
|
||||||
dependsOn("wrapper", bintrayUpload)
|
dependsOn("wrapper", bintrayUpload)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun findProperty(s: String) = project.findProperty(s) as String?
|
||||||
|
bintray {
|
||||||
|
user = findProperty("bintray.user")
|
||||||
|
key = findProperty("bintray.apikey")
|
||||||
|
publish = isRelease
|
||||||
|
setPublications(publicationName)
|
||||||
|
pkg.apply {
|
||||||
|
repo = "maven"
|
||||||
|
name = project.name
|
||||||
|
desc = description
|
||||||
|
websiteUrl = mavenUrl
|
||||||
|
issueTrackerUrl = "$mavenUrl/issues"
|
||||||
|
githubRepo = gitHub
|
||||||
|
githubReleaseNotesFile = "README.md"
|
||||||
|
vcsUrl = "$mavenUrl.git"
|
||||||
|
setLabels("kotlin", "java", "pinboard", "poster", "bookmarks")
|
||||||
|
publicDownloadNumbers = true
|
||||||
|
version.apply {
|
||||||
|
name = project.version as String
|
||||||
|
desc = description
|
||||||
|
vcsTag = project.version as String
|
||||||
|
gpg.apply {
|
||||||
|
sign = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
create<MavenPublication>(publicationName) {
|
||||||
|
from(components["java"])
|
||||||
|
artifact(sourcesJar)
|
||||||
|
artifact(javadocJar)
|
||||||
|
pom.withXml {
|
||||||
|
asNode().apply {
|
||||||
|
appendNode("name", project.name)
|
||||||
|
appendNode("description", project.description)
|
||||||
|
appendNode("url", mavenUrl)
|
||||||
|
|
||||||
|
appendNode("licenses").appendNode("license").apply {
|
||||||
|
appendNode("name", "BSD 3-Clause")
|
||||||
|
appendNode("url", "https://opensource.org/licenses/BSD-3-Clause")
|
||||||
|
}
|
||||||
|
|
||||||
|
appendNode("developers").appendNode("developer").apply {
|
||||||
|
appendNode("id", "ethauvin")
|
||||||
|
appendNode("name", "Erik C. Thauvin")
|
||||||
|
appendNode("email", "erik@thauvin.net")
|
||||||
|
}
|
||||||
|
|
||||||
|
appendNode("scm").apply {
|
||||||
|
appendNode("connection", "scm:git:$mavenUrl.git")
|
||||||
|
appendNode("developerConnection", "scm:git:git@github.com:$gitHub.git")
|
||||||
|
appendNode("url", mavenUrl)
|
||||||
|
}
|
||||||
|
|
||||||
|
appendNode("issueManagement").apply {
|
||||||
|
appendNode("system", "GitHub")
|
||||||
|
appendNode("url", "$mavenUrl/issues")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue