Skip to content

Commit

Permalink
Add configuration to publish to maven central (#11)
Browse files Browse the repository at this point in the history
* Add configuration to publish to maven central.
Upgrade to gradle 6.0.1.

* Fix build by making nexus username and password nullable for when they're not present on travis.
Update readme also.
  • Loading branch information
hanleyt authored Dec 28, 2019
1 parent bdcc011 commit 35fc243
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 20 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ Temporary Items
build/
out/

#Ignore gradle properties file as this contains maven central passwords
gradle.properties

#Ignore secret keys file for uploading to maven central
*.gpg

# Ignore Gradle GUI config
gradle-app.setting

Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ A zero dependency [JUnit 5 extension](https://junit.org/junit5/docs/current/user

[![Build Status](https://travis-ci.org/hanleyt/jersey-junit.svg?branch=master)](https://travis-ci.org/hanleyt/jersey-junit)
[![codecov](https://codecov.io/gh/hanleyt/jersey-junit/branch/master/graph/badge.svg)](https://codecov.io/gh/hanleyt/jersey-junit)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.hanleyt/jersey-junit/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.hanleyt/jersey-junit)
[![jitpack](https://jitpack.io/v/hanleyt/jersey-junit.svg)](https://jitpack.io/#hanleyt/jersey-junit)

Set Up
Expand All @@ -15,9 +16,13 @@ testCompile group: 'com.github.hanleyt', name: 'jersey-junit', version: '2.1.0'
testCompile group: 'org.glassfish.jersey.test-framework.providers', name: 'jersey-test-framework-provider-grizzly2', version: '2.28'
```

Ensuring you have the jitpack repo in your list of repos:
The library is available from the maven central repository from version `2.1.0` onwards.

```maven { url 'https://jitpack.io/' }```
```repositories { mavenCentral() }```

If you need an earlier version you can find it on the jitpack repo.

```repositories { maven { url 'https://jitpack.io/' } }```

Note you must be using [JUnit 5.1](https://junit.org/junit5/docs/current/release-notes/index.html#release-notes-5.1.0) or higher.

Expand Down
78 changes: 63 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ plugins {
java
idea
jacoco
maven
`maven-publish`
signing
}

group = "com.github.hanleyt"
version = "2.1.0"
version = "2.1.1-SNAPSHOT"

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

repositories {
Expand All @@ -24,11 +27,6 @@ jacoco {
toolVersion = "0.8.2"
}

val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}

tasks {

withType<Test> {
Expand All @@ -51,21 +49,71 @@ tasks {
dependsOn(jacocoTestReport)
}

artifacts {
archives(sourcesJar)
}

withType<Wrapper> {
gradleVersion = "5.3.1"
gradleVersion = "6.0.1"
}
}

dependencies {
compileOnly("org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion")
compileOnly("org.glassfish.jersey.test-framework:jersey-test-framework-core:$jerseyVersion")

testCompile("org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion")
testImplementation("org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion")

testCompile("org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-grizzly2:$jerseyVersion")
testCompile("org.glassfish.jersey.inject:jersey-hk2:$jerseyVersion")
testImplementation("org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-grizzly2:$jerseyVersion")
testImplementation("org.glassfish.jersey.inject:jersey-hk2:$jerseyVersion")
}

publishing {
publications {
create<MavenPublication>("jerseyJunit") {
groupId = project.group as String
artifactId = "jersey-junit"
version = project.version as String
from(components["java"])

pom {

name.set("Jersey JUnit")
description.set("A JUnit 5 extension library for testing JAX-RS and Jersey-based applications using the Jersey test framework.")
url.set("https://github.com/hanleyt/jersey-junit")
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("hanleyt")
name.set("Tom Hanley")
}
}
scm {
connection.set("scm:git:git://github.com/hanleyt/jersey-junit.git")
developerConnection.set("scm:git:ssh://github.com/hanleyt/jersey-junit.git")
url.set("https://github.com/hanleyt/jersey-junit/")
}
}
}
}


repositories {
maven {
val nexusUsername: String? by project
val nexusPassword: String? by project
credentials {
username = nexusUsername
password = nexusPassword
}
val snapshotsRepoUrl = uri("https://oss.sonatype.org/content/repositories/snapshots")
val releasesRepoUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2")
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
}
}
}

signing {
sign(publishing.publications["jerseyJunit"])
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
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.3.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 17 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/usr/bin/env sh

#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

##############################################################################
##
## Gradle start up script for UN*X
Expand Down Expand Up @@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"'
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
Expand Down
18 changes: 17 additions & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
Expand All @@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m"
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
Expand Down

0 comments on commit 35fc243

Please sign in to comment.