Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maven central migration #2

Merged
merged 9 commits into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Set up Maven Central publishing, prepare 3.0.0 release
  • Loading branch information
reisub committed Mar 11, 2021
commit b5c54d1cd96102263ef9fadd322847cc85cb1509
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changelog
=========

## Version 3.0.0

_2021-03-11_

- use [Thrifty 2.1.2](https://github.com/microsoft/thrifty/blob/master/CHANGELOG.md)
- use Okio 2.10.0, OkHttp 4.9.1, Kotlin 1.4.30
- migrate deployment to Maven Central
- change group id `co.infinum` -> `com.infinum`
- change package name `co.infinum` -> `com.infinum`

## Version 2.0.0

_2020-06-01_
Expand Down
33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Thrifty Retrofit converter

[![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
[![Download](https://api.bintray.com/packages/infinum/android/retrofit-converter-thrifty/images/download.svg) ](https://bintray.com/infinum/android/retrofit-converter-thrifty/_latestVersion)

A `Retrofit converter` implementation using [Thrifty](https://github.com/Microsoft/thrifty) for
(de)serialization of Apache Thrift requests and responses.
Expand All @@ -11,10 +10,10 @@ It supports Thrifty models generated in both `Java` and `Kotlin`.

## Usage

Add the library as a dependency to your `build.gradle` to automatically download it from jcenter.
Add the library as a dependency to your `build.gradle` to automatically download it from Maven Central.

```groovy
compile 'co.infinum:retrofit-converter-thrifty:2.0.0'
implementation "com.infinum:retrofit-converter-thrifty:3.0.0"
```

... and add the converter factory when you create the `Retrofit` object.
Expand All @@ -28,26 +27,38 @@ Retrofit retrofit = new Retrofit.Builder()

We also maintain a [changelog](CHANGELOG.md).

## Generating new files with thrifty compiler
## Contributing

Feedback and code contributions are very much welcome. Just make a pull request with a short description of your changes. By making contributions to this project you give permission for your code to be used under the same [license](LICENSE).

### Generating new files with the thrifty compiler

In case source files need to be generated from .thrift files using a different version of the thrifty compiler, use these commands:

```shell
wget https://repo1.maven.org/maven2/com/microsoft/thrifty/thrifty-compiler/2.1.2/thrifty-compiler-2.1.2-all.jar
java -jar thrifty-compiler-2.1.2-all.jar --out=retrofit-converter-thrifty/src/test/java/ --lang=java retrofit-converter-thrifty/src/test/resources/phone.thrift
java -jar thrifty-compiler-2.1.2-all.jar --out=retrofit-converter-thrifty/src/test/kotlin/ --lang=kotlin --kt-file-per-type retrofit-converter-thrifty/src/test/resources/phone.thrift

```

## Deploying a new version
### Deploying a new version

To publish to Maven Central you first need to set the following [Gradle properties](https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties):

To deploy a new version to bintray, use `deploy.sh`:
```
signing.keyId=<GPG_KEY_ID>
signing.password=<GPG_KEY_PASSWORD>
signing.secretKeyRingFile=<GPG_SECRING_LOCATION>

sonatype.url=https://oss.sonatype.org/service/local/staging/deploy/maven2/
sonatype.username=<SONATYPE_USERNAME>
sonatype.password=<SONATYPE_PASSWORD>
```

To deploy a new version to Maven Central, use `deploy.sh`:

```shell
./deploy.sh <bintray username> <bintray api key> <artifact version> [optional tag message]
./publish.sh <artifact version> [optional tag message]
```

## Contributing

Feedback and code contributions are very much welcome. Just make a pull request with a short description of your changes. By making contributions to this project you give permission for your code to be used under the same [license](LICENSE).
The publish script will automatically push a tag with the version name and change the version in the README.
5 changes: 2 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
buildscript {
repositories {
maven { url = uri("https://plugins.gradle.org/m2/") }
jcenter()
mavenCentral()
}
dependencies {
classpath("com.novoda:bintray-release:0.9.1")
}
}

allprojects {
repositories {
jcenter()
mavenCentral()
}
}
26 changes: 0 additions & 26 deletions deploy.sh

This file was deleted.

51 changes: 51 additions & 0 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash

######################################################################################################
#
# This deploy script requires have all the necessary gradle properties already set up:
# - signing.keyId
# - signing.password
# - signing.secretKeyRingFile
# - sonatype.url
# - sonatype.username
# - sonatype.password
#
######################################################################################################

# Stop script on errors or undefined vars
set -euo pipefail;

readonly SCRIPT_NAME="$(basename "$0")"
readonly green="\e[0;32m"
readonly reset="\e[0m"

if [ $# -lt 1 ]; then
echo
echo "Usage:"
echo -e "${green}$SCRIPT_NAME <version> [optional tag message]${reset}"
exit 1
fi

readonly version="$1"

# default tag message
tag_message="$version release"

if [ -n "${2-}" ]; then
tag_message="$2"
fi

echo -e "${green}Building and uploading release ...${reset}"
./gradlew clean build publishLibraryPublicationToSonatypeRepository

echo -e "${green}Pushing version tag ...${reset}"
git tag -a "${version}" -m "${tag_message}" && \
git push --tags

# fix version in README.md if needed
echo -e "${green}Setting version in README.md to $version ...${reset}"
sed -E "s/\"com.infinum:retrofit-converter-thrifty:[\.0-9]+\"/\"com.infinum:retrofit-converter-thrifty:$version\"/g" README.md > tmp_readme && mv tmp_readme README.md

# show changes so we know to commit if needed
echo -e "${green}\nHere's the output of git status:\n${reset}"
git status
76 changes: 62 additions & 14 deletions retrofit-converter-thrifty/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import com.novoda.gradle.release.PublishExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.URI

plugins {
id("java")
kotlin("jvm") version "1.4.30"
id("jacoco")
id("com.novoda.bintray-release")
id("maven-publish")
id("signing")
}

group = "com.infinum"
version = "3.0.0"

java {
withJavadocJar()
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

group = "co.infinum"
version = "2.0.0"

object Versions {
const val thrifty_version = "2.1.2"
const val retrofit_version = "2.9.0"
Expand Down Expand Up @@ -56,13 +59,58 @@ tasks.withType<KotlinCompile>().configureEach {
}
}

configure<PublishExtension> {
userOrg = "infinum"
groupId = project.group.toString()
artifactId = "retrofit-converter-thrifty"
publishVersion = project.version.toString()
desc = "Retrofit converter for Thrifty implementation of Apache Thrift"
website = "https://github.com/infinum/thrifty-retrofit-converter"
repoName = "android"
setLicences("Apache-2.0")
publishing {
repositories {
maven {
name = "Sonatype"
url = URI.create(project.property("sonatype.url") as String)
credentials {
username = project.property("sonatype.username") as String
password = project.property("sonatype.password") as String
}
}
}
publications {
create<MavenPublication>("library") {
groupId = project.group as String?
artifactId = project.name
version = project.version as String?

from(components["java"])

pom {
name.set("Thrifty Retrofit converter")
description.set("Retrofit converter for Thrifty implementation of Apache Thrift")
url.set("https://github.com/infinum/thrifty-retrofit-converter")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("reisub")
name.set("Dino Kovač")
email.set("dino@infinum.com")
}
}
scm {
connection.set("scm:git:git://github.com/infinum/thrifty-retrofit-converter.git")
developerConnection.set("scm:git:ssh://github.com/infinum/thrifty-retrofit-converter.git")
url.set("https://github.com/infinum/thrifty-retrofit-converter")
}
}
}
}
}

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

tasks.javadoc {
if (JavaVersion.current().isJava9Compatible) {
(options as StandardJavadocDocletOptions).addBooleanOption("html5", true)
}
}