Skip to content

Commit

Permalink
Merge pull request #1 from telekom/feature/publish-mvn-central
Browse files Browse the repository at this point in the history
Added Support for Maven Central
  • Loading branch information
martingrossmann authored Mar 26, 2021
2 parents 13c6c4c + 13b9692 commit 55132c3
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 97 deletions.
41 changes: 19 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Testerra AzureDevOps Connector

<p align="center">
<a href="https://mvnrepository.com/artifact/io.testerra/azure-devops-connector" title="MavenCentral"><img src="https://img.shields.io/maven-central/v/io.testerra/azure-devops-connector?label=Maven%20Central"></a>
<a href="/../../commits/" title="Last Commit"><img src="https://img.shields.io/github/last-commit/telekom/testerra-azure-devops-connector?style=flat"></a>
<a href="/../../issues" title="Open Issues"><img src="https://img.shields.io/github/issues/telekom/testerra-azure-devops-connector?style=flat"></a>
<a href="./LICENSE" title="License"><img src="https://img.shields.io/badge/License-Apache%202.0-green.svg?style=flat"></a>
Expand All @@ -27,23 +28,23 @@ It will register automatically by using Testerra `ModuleHook`, but you have to p

### Requirements

* Testerra in Version: `1.0-RC-30`
![Maven Central](https://img.shields.io/maven-central/v/io.testerra/core/1.0-RC-32?label=Testerra)

### Usage

Include the following dependency in your project.

Gradle:
````groovy
implementation 'eu.tsystems.mms.tic.testerra:azure-devops-connector:1.0-RC-2'
implementation 'eu.tsystems.mms.tic.testerra:azure-devops-connector:1.0'
````

Maven:
````xml
<dependency>
<groupId>eu.tsystems.mms.tic.testerra</groupId>
<artifactId>azure-devops-connector</artifactId>
<version>1.0-RC-2</version>
<version>1.0</version>
</dependency>
````

Expand Down Expand Up @@ -81,28 +82,24 @@ public void test_case_01() {

## Publication

### ... to a Maven repo
This module is deployed and published to Maven Central. All JAR files are signed via Gradle signing plugin.

_Publishing to local repo_
```shell
gradle publishToMavenLocal
```
The following properties have to be set via command line or ``~/.gradle/gradle.properties``

_Publishing to remote repo_
```shell
gradle publish -DdeployUrl=<repo-url> -DdeployUsername=<repo-user> -DdeployPassword=<repo-password>
```
| Property | Description |
| ----------------------------- | --------------------------------------------------- |
| `moduleVersion` | Version of deployed module, default is `1-SNAPSHOT` |
| `deployUrl` | Maven repository URL |
| `deployUsername` | Maven repository username |
| `deployPassword` | Maven repository password |
| `signing.keyId` | GPG private key ID (short form) |
| `signing.password` | GPG private key password |
| `signing.secretKeyRingFile` | Path to GPG private key |

_Set a custom version_
```shell
gradle publish -DmoduleVersion=<version>
```
### ... to GitHub Packages

Some hints for using GitHub Packages as Maven repository

* Deploy URL is https://maven.pkg.github.com/OWNER/REPOSITRY
* As password generate an access token and grant permissions to ``write:packages`` (Settings -> Developer settings -> Personal access token)
If all properties are set, call the following to build, deploy and release this module:
````shell
gradle publish closeAndReleaseRepository
````

## Code of Conduct

Expand Down
18 changes: 12 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
plugins {
id "io.codearte.nexus-staging" version "0.30.0"
}

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'io.codearte.nexus-staging'

ext {
// Minimum required Testerra version
testerraCompileVersion = '1.0-RC-30'
testerraCompileVersion = '1.0-RC-32'
// Unit tests use the latest Testerra version
testerraTestVersion = '[1.0-RC,2-SNAPSHOT)'

Expand All @@ -14,16 +20,16 @@ ext {
moduleVersion = System.getProperty('moduleVersion')
}

group 'eu.tsystems.mms.tic.testerra'
group 'io.testerra'
version moduleVersion
}

// Do not move this integration because `group` and `version` is needed for publishing
apply from: rootProject.file('publish.gradle')

dependencies {
compileOnly 'eu.tsystems.mms.tic.testerra:core:' + testerraCompileVersion
implementation 'eu.tsystems.mms.tic.testerra:surefire-connector:' + testerraCompileVersion
compileOnly 'io.testerra:core:' + testerraCompileVersion
implementation 'io.testerra:surefire-connector:' + testerraCompileVersion

implementation 'org.apache.commons:commons-lang3:3.9'
implementation 'org.apache.httpcomponents:httpcore:4.4.13'
Expand All @@ -34,8 +40,8 @@ dependencies {
// Better JSON mapper for Jersey
implementation 'com.owlike:genson:1.6'

testImplementation 'eu.tsystems.mms.tic.testerra:core:' + testerraTestVersion
testImplementation 'eu.tsystems.mms.tic.testerra:report:' + testerraTestVersion
testImplementation 'io.testerra:core:' + testerraTestVersion
testImplementation 'io.testerra:report:' + testerraTestVersion

}

Expand Down
163 changes: 94 additions & 69 deletions publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,94 +2,119 @@
* Maven publishing configuration
* */

// Maven basis attributes
// Maven pom.xml attributes
ext {
libraryName = 'Testerra'
artifact = project.getName().toLowerCase()
packagingType = 'jar'
libraryName = 'Testerra TeamCity Connector'
packagingType = 'jar'

libraryDescription = "Testerra ${project.getName()} module"
siteUrl = 'https://testerra.io'
gitUrl = 'scm:git:git://github.com/telekom/testerra-azure-devops-connector.git'
gitHttpsUrl = 'https://github.com/telekom/testerra-azure-devops-connector/'

siteUrl = 'https://testerra.io'
gitUrl = 'https://github.com/telekom/testerra-selenoid-connector.git'
issueUrl = 'https://github.com/telekom/testerra-selenoid-connector/issues'
developerId = 'MMS'
developerName = 'Testerra Team T-Systems MMS'
developerEmail = '[email protected]'
developerOrganization = 'T-Systems MMS'
developerOrganizationUrl = 'https://www.t-systems-mms.com/'

developerId = 'MMS'
developerName = 'Testerra Team T-Systems MMS'
developerEmail = '[email protected]'

licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}

// Set up the Maven publication.
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom.project {
packaging packagingType
groupId group
artifactId artifact

// Add your description here
name libraryName
description libraryDescription
url siteUrl

// Set your license
licenses {
license {
name licenseName
url licenseUrl
}
}
developers {
developer {
id developerId
name developerName
email developerEmail
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}

}
}
nexusStaging {
serverUrl = "https://s01.oss.sonatype.org/service/local/"
packageGroup = "io.testerra"
username = System.getProperty("deployUsername")
password = System.getProperty("deployPassword")
}


// Publish to a Maven repository
allprojects {

publishing {
def libraryDescription = "Testerra test automation framework - ${project.getName()} module"

javadoc {
// Support JDK 8 annotations
options.tags = [
"implNote:a:Implementation Note:",
"apiNote:a:API Note:",
"implSpec:a:Implementation Requirements:"
]
// Prevent errors during generation
options.addStringOption('Xdoclint:none', '-quiet')
}

task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
archiveClassifier.set('sources')
from sourceSets.main.allSource
}

artifacts {
archives sourcesJar
task javadocJar(type: Jar) {
archiveClassifier.set('javadoc')
from javadoc
}

publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
}
artifacts {
archives sourcesJar
archives javadocJar
}

repositories {
maven {
url System.getProperty("deployUrl", "none")
credentials {
username System.getProperty("deployUsername", "none")
password System.getProperty("deployPassword", "none")
publishing {

publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar

// Custom pom
pom {

name = libraryName
description = libraryDescription
url = siteUrl

licenses {
license {
name = licenseName
url = licenseUrl
}
}

developers {
developer {
id = developerId
name = developerName
email = developerEmail
organization = developerOrganization
organizationUrl = developerOrganizationUrl
}
}

scm {
connection = gitUrl
developerConnection = gitUrl
url = gitHttpsUrl
}
}
}
}
}

repositories {
maven {
url System.getProperty("deployUrl", "none")
credentials {
username System.getProperty("deployUsername", "none")
password System.getProperty("deployPassword", "none")
}
}
}

signing {
sign publishing.publications.mavenJava
}

}
}
}

0 comments on commit 55132c3

Please sign in to comment.