Skip to content

Commit ed01599

Browse files
authored
Merge pull request #3 from inwx/maven_publishing
Makes project ready for maven central
2 parents 49a0773 + 01ffcf8 commit ed01599

7 files changed

+105
-25
lines changed

README.md

+5-13
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,23 @@ If you still experience any kind of problems don't hesitate to contact our [supp
1818

1919
Installation
2020
-------
21-
Currently you have to publish the gradle project to your local repository.
22-
23-
#### Build the project and publish it to your local maven repository:
24-
```bash
25-
./gradlew publishToMavenLocal
26-
```
2721

2822
#### Add the domrobot as a dependency:
2923

3024
If you use gradle:
3125
```gradle
32-
compile 'com.inwx.domrobot:java-client:3.0'
26+
compile 'com.inwx:domrobot:3.1'
3327
```
3428

3529
Or if you use maven:
3630
```xml
3731
<dependency>
38-
<groupId>com.inwx.domrobot</groupId>
39-
<artifactId>java-client</artifactId>
40-
<version>3.0</version>
32+
<groupId>com.inwx</groupId>
33+
<artifactId>domrobot</artifactId>
34+
<version>3.1</version>
4135
</dependency>
4236
```
4337

44-
We are working on getting it into the official maven repository.
45-
4638
Example
4739
-------
4840

@@ -58,7 +50,7 @@ public class DomaincheckExample {
5850

5951
String username = "";
6052
String password = "";
61-
String sharedSecret = "";
53+
String sharedSecret = ""; // Only necessary if 2FA is enabled.
6254
String domain = "my-test-domain-which-is-definitely-not-registered6737.com";
6355

6456
// By default the ApiClient uses the test api (OT&E). If you want to use the production/live api

build.gradle

+3-9
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ plugins {
44
id 'maven-publish'
55
}
66

7-
group 'com.inwx.domrobot'
8-
version '3.0'
7+
group 'com.inwx'
8+
version '3.1'
99

1010
allprojects {
1111
if (project.plugins.hasPlugin('java')) {
@@ -23,10 +23,4 @@ dependencies {
2323
implementation 'org.apache.httpcomponents:httpclient:4.5.9'
2424
}
2525

26-
publishing {
27-
publications {
28-
maven(MavenPublication) {
29-
from components.java
30-
}
31-
}
32-
}
26+
apply from: './deploy.gradle'

deploy.gradle

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
apply plugin: 'maven-publish'
2+
apply plugin: 'signing'
3+
4+
gradle.taskGraph.whenReady { taskGraph ->
5+
if (taskGraph.allTasks.any { it instanceof Sign } && project.ext.isReleaseVersion) {
6+
def id = System.getenv('GPG_ID') ?: $GPG_ID
7+
def file = System.getenv('GPG_SECRET_KEY_RING_FILE') ?: $GPG_SECRET_KEY_RING_FILE
8+
def password = System.getenv('GPG_PASSWORD') ?: $GPG_PASSWORD
9+
10+
allprojects { ext."signing.keyId" = id }
11+
allprojects { ext."signing.secretKeyRingFile" = file }
12+
allprojects { ext."signing.password" = password }
13+
}
14+
}
15+
16+
ext {
17+
isReleaseVersion = !(project.version =~ /-SNAPSHOT$/)
18+
isNeedSign = System.getenv('GPG_ID') && isReleaseVersion
19+
}
20+
21+
task sourcesJar(type: Jar) {
22+
from sourceSets.main.allJava
23+
archiveClassifier.set('sources')
24+
}
25+
26+
task javadocJar(type: Jar) {
27+
from javadoc
28+
archiveClassifier.set('javadoc')
29+
}
30+
31+
publishing {
32+
publications {
33+
mavenJava(MavenPublication) {
34+
35+
from components.java
36+
artifact sourcesJar
37+
artifact javadocJar
38+
39+
pom {
40+
name = 'INWX Domrobot Java Client'
41+
description = 'INWX Domrobot Java Client'
42+
url = 'https://github.com/inwx/java-client'
43+
licenses {
44+
license {
45+
name = 'MIT License'
46+
url = 'http://www.opensource.org/licenses/mit-license.php'
47+
distribution = 'repo'
48+
}
49+
}
50+
developers {
51+
developer {
52+
id = 'developer-inwx'
53+
name = 'INWX Developer'
54+
55+
organization = 'INWX GmbH & Co. KG'
56+
organizationUrl = 'https://www.inwx.com/en/'
57+
}
58+
}
59+
scm {
60+
connection = 'scm:git:git://github.com/inwx/java-client.git'
61+
developerConnection = 'scm:git:[email protected]:inwx/java-client.git'
62+
url = 'https://github.com/inwx/java-client'
63+
}
64+
}
65+
}
66+
}
67+
repositories {
68+
maven {
69+
credentials {
70+
username System.getenv('OSSRH_USER') ?: $OSSRH_USER
71+
password System.getenv('OSSRH_PASS') ?: $OSSRH_PASS
72+
}
73+
if (project.ext.isReleaseVersion) {
74+
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
75+
} else {
76+
url "https://oss.sonatype.org/content/repositories/snapshots"
77+
}
78+
}
79+
}
80+
81+
signing {
82+
required { project.ext.isNeedSign }
83+
sign publishing.publications.mavenJava
84+
}
85+
}

examples/src/main/java/com/inwx/domrobot/DomaincheckExample.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static void main(String[] args) throws Exception {
99

1010
String username = "";
1111
String password = "";
12-
String sharedSecret = "";
12+
String sharedSecret = ""; // Only necessary if 2FA is enabled.
1313
String domain = "my-test-domain-which-is-definitely-not-registered6737.com";
1414

1515
// By default the ApiClient uses the test api (OT&E). If you want to use the production/live api

examples/src/main/java/com/inwx/domrobot/DomaincheckWithCustomModelsExample.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static void main(String[] args) throws Exception {
1212

1313
String username = "";
1414
String password = "";
15-
String sharedSecret = "";
15+
String sharedSecret = ""; // Only necessary if 2FA is enabled.
1616
String domain = "my-test-domain-which-is-definitely-not-registered6737.com";
1717

1818
ApiClient client = new ApiClient(ApiClient.OTE_URL, true);

gradle.properties

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Signing settings
2+
$GPG_ID=
3+
## Must be absolute path
4+
$GPG_SECRET_KEY_RING_FILE=
5+
$GPG_PASSWORD=
6+
7+
# Publish settings
8+
$OSSRH_USER=
9+
$OSSRH_PASS=

settings.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
rootProject.name = 'java-client'
1+
rootProject.name = 'domrobot'
22
include 'examples'
33

0 commit comments

Comments
 (0)