Skip to content

Commit

Permalink
Add publishing to MavenCentral instead of jcenter
Browse files Browse the repository at this point in the history
Closes #19
  • Loading branch information
LeoColman committed Apr 16, 2021
1 parent 7ff50d7 commit 40c5875
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 81 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "daily"
29 changes: 29 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: '🧰 Maintenance'
label: 'chore'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
template: |
## Changes
$CHANGES
14 changes: 14 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Build
on:
pull_request:
paths-ignore:
- '*.md'
push:
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: check
run: ./gradlew check
14 changes: 14 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Release Drafter

on:
push:
branches:
- master

jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release

on:
workflow_dispatch:
inputs:
version:
description: "Release Version"
required: true

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Publish to Maven Central
run: ./gradlew publish
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,8 @@ This library comes to the rescue of programmers dealing with fixed length files.

## Using with Gradle

This library is published to `Bintray jcenter`, so you'll need to configure that in your repositories:
```kotlin
repositories {
mavenCentral()
jcenter()
}
```
Import it into your dependencies:

And then you can import it into your dependencies:
```kotlin
dependencies {
implementation("br.com.guiabolso:FixedLengthFileHandler:{version}")
Expand Down
112 changes: 58 additions & 54 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,42 +1,29 @@
import com.novoda.gradle.release.PublishExtension
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

buildscript {
repositories {
mavenCentral()
jcenter()
}

dependencies {
classpath("com.novoda:bintray-release:0.9.1")
}
}
import java.lang.System.getenv

plugins {
kotlin("jvm") version "1.3.61"

kotlin("jvm") version "1.4.31"
`maven-publish`
id("org.jetbrains.dokka") version "0.9.17"
id("io.gitlab.arturbosch.detekt").version("1.1.1")
signing
id("io.gitlab.arturbosch.detekt").version("1.16.0")
}

apply(plugin = "com.novoda.bintray-release")

group = "br.com.guiabolso"
version = "0.5.0"
version = getenv("RELEASE_VERSION") ?: "local"

repositories {
mavenCentral()
jcenter()
mavenCentral()
}

repositories {
mavenCentral()
}

dependencies {
// Kotlin
implementation(kotlin("stdlib-jdk8"))
implementation(kotlin("reflect"))


// KotlinTest
testImplementation("io.kotlintest:kotlintest-runner-junit5:3.4.2")
}
Expand All @@ -49,65 +36,82 @@ tasks.withType<Test> {
useJUnitPlatform()
}

val sourcesJar by tasks.registering(Jar::class) {
classifier = "sources"
from(sourceSets.getByName("main").allSource)
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}

val javadocJar by tasks.registering(Jar::class) {
val javadoc = tasks["dokka"] as DokkaTask
javadoc.outputFormat = "javadoc"
javadoc.outputDirectory = "$buildDir/javadoc"
dependsOn(javadoc)
classifier = "javadoc"
from(javadoc.outputDirectory)
val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.getByName("main").allSource)
}

detekt {
toolVersion = "1.1.1"
input = files("src/main/kotlin", "src/test/kotlin")
val javadoc = tasks.named("javadoc")
val javadocsJar by tasks.creating(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles java doc to jar"
archiveClassifier.set("javadoc")
from(javadoc)
}

publishing {

repositories {
maven {
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = getenv("OSSRH_USERNAME")
password = getenv("OSSRH_PASSWORD")
}
}
}

publications {

register("maven", MavenPublication::class) {
from(components["java"])
artifact(sourcesJar.get())
artifact(javadocJar.get())
artifact(javadocsJar)

pom {
name.set("Fixed-Length-File-Handler")
description.set("Fixed-Length-File-Handler")
url.set("https://github.com/GuiaBolso/fixed-length-file-handler")


scm {
connection.set("scm:git:https://github.com/GuiaBolso/fixed-length-file-handler/")
developerConnection.set("scm:git:https://github.com/GuiaBolso/")
url.set("https://github.com/GuiaBolso/fixed-length-file-handler")
}

licenses {
license {
name.set("The Apache 2.0 License")
url.set("https://opensource.org/licenses/Apache-2.0")
}
}

developers {
developer {
id.set("Guiabolso")
name.set("Guiabolso")
}
}
}
}
}
}

configure<PublishExtension> {
artifactId = "fixed-length-file-handler"
autoPublish = true
desc = "Fixed Length File Handler"
groupId = "br.com.guiabolso"
userOrg = "gb-opensource"
setLicences("APACHE-2.0")
publishVersion = version.toString()
uploadName = "Fixed-Length-File-Handler"
website = "https://github.com/GuiaBolso/fixed-length-file-handler"
setPublications("maven")
}
signing {
val signingKey: String? by project
val signingPassword: String? by project

useGpgCmd()
if (signingKey != null && signingPassword != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
}

sign((extensions.getByName("publishing") as PublishingExtension).publications)
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
3 changes: 0 additions & 3 deletions upload-bintray.sh

This file was deleted.

0 comments on commit 40c5875

Please sign in to comment.