Skip to content

Commit f6d5d63

Browse files
committed
Update gradle process. Try build and prep ability to push to oss.sonatype.org
1 parent ee9ffc9 commit f6d5d63

File tree

4 files changed

+141
-131
lines changed

4 files changed

+141
-131
lines changed

.github/workflows/publish.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Publish to OSSRH
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
16+
- name: Setup Java
17+
uses: actions/setup-java@v2
18+
with:
19+
java-version: '11'
20+
distribution: 'adopt'
21+
22+
- name: Cache Gradle packages
23+
uses: actions/cache@v2
24+
with:
25+
path: ~/.gradle/caches
26+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
27+
restore-keys: ${{ runner.os }}-gradle
28+
29+
- name: Build
30+
run: ./gradlew build
31+
# env:
32+
# OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
33+
# OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
Lines changed: 47 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1+
// Apply necessary plugins
12
apply plugin: 'com.android.library'
2-
apply plugin: 'com.github.dcendents.android-maven'
3-
apply plugin: 'com.jfrog.bintray'
4-
5-
version = "1.0.49"
3+
apply plugin: 'maven-publish'
64

5+
// Define the version and group for the Maven package
6+
version = "1.0.50"
7+
group = "net.servicestack"
8+
// Specify dependencies
79
dependencies {
8-
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
9-
implementation 'com.squareup.okhttp3:okhttp:3.12.1'
10+
implementation 'com.google.code.gson:gson:2.8.9'
11+
implementation 'com.squareup.okhttp3:okhttp:4.4.1'
1012
implementation fileTree(include: '*.jar', dir: 'libs')
11-
androidTestImplementation 'junit:junit:4.12'
13+
androidTestImplementation 'junit:junit:4.13.1'
1214
androidTestImplementation 'com.android.support.test:runner:1.0.2'
1315
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
1416
androidTestImplementation 'com.android.support:support-annotations:28.0.0'
1517
}
1618

19+
// Android specific configurations
1720
android {
18-
compileSdkVersion 29
21+
compileSdkVersion 31
1922
buildToolsVersion '29.0.2'
2023

2124
lintOptions {
@@ -24,7 +27,7 @@ android {
2427

2528
defaultConfig {
2629
minSdkVersion 15
27-
targetSdkVersion 29
30+
targetSdkVersion 31
2831
versionCode 1
2932
versionName version
3033

@@ -41,74 +44,58 @@ android {
4144
}
4245
}
4346

44-
Properties properties = System.properties;
45-
if(properties.getProperty("bintray.user", null) == null) {
46-
properties.load(project.file('./local.properties').newDataInputStream())
47-
}
48-
49-
def siteUrl = 'https://github.com/ServiceStack/ServiceStack.Java' // Homepage URL of the library
50-
def gitUrl = 'https://github.com/ServiceStack/ServiceStack.Java.git' // Git repository URL
51-
group = "net.servicestack" // Maven Group ID for the artifact
52-
53-
bintray {
54-
user = properties.getProperty("bintray.user")
55-
key = properties.getProperty("bintray.apiKey")
56-
57-
configurations = ['archives']
58-
pkg {
59-
repo = "maven"
60-
name = "ServiceStack.Android"
61-
websiteUrl = siteUrl
62-
vcsUrl = gitUrl
63-
licenses = ["BSD 3-Clause"]
64-
publish = properties.getProperty('bintray.publish') == 'true'
65-
userOrg = 'servicestack'
66-
}
67-
}
47+
// Configure the publishing block for Maven Central deployment
48+
publishing {
49+
publications {
50+
mavenJava(MavenPublication) {
51+
artifact("$buildDir/outputs/aar/${project.name}-release.aar")
6852

69-
install {
70-
repositories.mavenInstaller {
71-
// This generates POM.xml with proper parameters
72-
pom {
73-
project {
74-
packaging 'aar'
53+
groupId = group
54+
artifactId = 'android'
55+
version = version
7556

76-
// Add your description here
77-
name 'ServiceStack.Android'
78-
description 'A client library to call your ServiceStack webservices for Android clients.'
79-
url siteUrl
57+
pom {
58+
name = 'ServiceStack.Android'
59+
description = 'A client library to call your ServiceStack webservices for Android clients.'
60+
url = 'https://github.com/ServiceStack/ServiceStack.Java'
8061

81-
// Set your license
8262
licenses {
8363
license {
84-
name 'The BSD 3-Clause License'
85-
url 'https://servicestack.net/bsd-license.txt'
64+
name = 'The BSD 3-Clause License'
65+
url = 'https://servicestack.net/bsd-license.txt'
8666
}
8767
}
8868

8969
developers {
9070
developer {
91-
id 'mythz'
92-
name 'Demis Bellot'
93-
email 'team@servicestack.net'
71+
id = 'mythz'
72+
name = 'Demis Bellot'
73+
email = 'team@servicestack.net'
9474
}
9575
developer {
96-
id 'layoric'
97-
name 'Darren Reid'
98-
email 'team@servicestack.net'
76+
id = 'layoric'
77+
name = 'Darren Reid'
78+
email = 'team@servicestack.net'
9979
}
10080
}
101-
scm {
102-
connection 'https://github.com/ServiceStack/ServiceStack.Java'
103-
developerConnection 'https://github.com/ServiceStack/ServiceStack.Java'
104-
url 'https://github.com/ServiceStack/ServiceStack.Java'
10581

82+
scm {
83+
connection = 'https://github.com/ServiceStack/ServiceStack.Java.git'
84+
developerConnection = 'https://github.com/ServiceStack/ServiceStack.Java.git'
85+
url = 'https://github.com/ServiceStack/ServiceStack.Java'
10686
}
10787
}
10888
}
10989
}
110-
}
11190

112-
repositories {
113-
mavenCentral()
114-
}
91+
repositories {
92+
maven {
93+
name = 'OSSRH'
94+
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
95+
credentials {
96+
username = project.findProperty("ossrhUsername") ?: System.getenv("OSSRH_USERNAME")
97+
password = project.findProperty("ossrhPassword") ?: System.getenv("OSSRH_TOKEN")
98+
}
99+
}
100+
}
101+
}

src/AndroidClient/build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
buildscript {
44
ext.kotlin_version = '1.3.61'
55
repositories {
6-
jcenter()
6+
mavenCentral()
77
maven {
88
url 'https://maven.google.com/'
99
name 'Google'
@@ -12,7 +12,6 @@ buildscript {
1212
}
1313
dependencies {
1414
classpath 'com.android.tools.build:gradle:4.0.0'
15-
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
1615
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
1716
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1817
// NOTE: Do not place your application dependencies here; they belong
@@ -22,7 +21,7 @@ buildscript {
2221

2322
allprojects {
2423
repositories {
25-
jcenter()
24+
mavenCentral()
2625
maven {
2726
url 'https://maven.google.com/'
2827
name 'Google'
Lines changed: 59 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,90 @@
1-
apply plugin: 'com.jfrog.bintray'
1+
// Apply necessary plugins
22
apply plugin: 'java'
3-
apply plugin: 'idea'
4-
apply plugin: 'maven'
3+
apply plugin: 'maven-publish'
54

6-
version = "1.0.49"
5+
// Define the version and group for the Maven package
6+
version = "1.0.50"
7+
group = "net.servicestack"
78

9+
// Specify dependencies
810
dependencies {
9-
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
10-
testImplementation 'junit:junit:4.12'
11+
implementation 'com.google.code.gson:gson:2.8.9'
12+
testImplementation 'junit:junit:4.13.1'
1113
testImplementation 'pl.pragmatists:JUnitParams:1.1.1'
1214
}
1315

14-
group = "net.servicestack" // Maven Group ID for the artifact
15-
String packageId = "client"
16-
String groupID = group
17-
String versionNum = version
18-
19-
String siteUrl = 'https://github.com/ServiceStack/ServiceStack.Java' // Homepage URL of the library
20-
String gitUrl = 'https://github.com/ServiceStack/ServiceStack.Java.git' // Git repository URL
16+
// Additional tasks for generating source and Javadoc JARs
17+
task sourcesJar(type: Jar) {
18+
from sourceSets.main.allJava
19+
archiveClassifier.set('sources')
20+
}
2121

22-
Properties properties = System.properties;
23-
if(properties.getProperty("bintray.user", null) == null) {
24-
properties.load(project.file('./local.properties').newDataInputStream())
22+
task javadocJar(type: Jar, dependsOn: javadoc) {
23+
from javadoc.destinationDir
24+
archiveClassifier.set('javadoc')
2525
}
2626

27-
install {
28-
repositories.mavenInstaller {
29-
pom {
30-
project {
31-
packaging 'jar'
32-
groupId groupID
33-
artifactId packageId
34-
version versionNum
35-
// Add your description here
36-
name 'ServiceStack.Client'
37-
description 'A client library to call your ServiceStack webservices.'
38-
url siteUrl
27+
// Configure the publishing block for Maven Central deployment
28+
publishing {
29+
publications {
30+
mavenJava(MavenPublication) {
31+
from components.java
3932

40-
// Set your license
33+
// Attach source and javadoc JARs
34+
artifact sourcesJar
35+
artifact javadocJar
36+
37+
pom {
38+
name = 'ServiceStack.Client'
39+
description = 'A client library to call your ServiceStack webservices.'
40+
url = 'https://github.com/ServiceStack/ServiceStack.Java'
41+
42+
version = version
4143
licenses {
4244
license {
43-
name 'The BSD 3-Clause License'
44-
url 'https://servicestack.net/bsd-license.txt'
45+
name = 'The BSD 3-Clause License'
46+
url = 'https://servicestack.net/bsd-license.txt'
4547
}
4648
}
4749

4850
developers {
4951
developer {
50-
id 'mythz'
51-
name 'Demis Bellot'
52-
email 'team@servicestack.net'
52+
id = 'mythz'
53+
name = 'Demis Bellot'
54+
email = 'team@servicestack.net'
5355
}
5456
developer {
55-
id 'layoric'
56-
name 'Darren Reid'
57-
email 'team@servicestack.net'
57+
id = 'layoric'
58+
name = 'Darren Reid'
59+
email = 'team@servicestack.net'
5860
}
5961
}
62+
6063
scm {
61-
connection 'https://github.com/ServiceStack/ServiceStack.Java'
62-
developerConnection 'https://github.com/ServiceStack/ServiceStack.Java'
63-
url 'https://github.com/ServiceStack/ServiceStack.Java'
64+
connection = 'https://github.com/ServiceStack/ServiceStack.Java.git'
65+
developerConnection = 'https://github.com/ServiceStack/ServiceStack.Java.git'
66+
url = 'https://github.com/ServiceStack/ServiceStack.Java'
6467
}
6568
}
66-
}.writeTo('pom.xml')
69+
}
6770
}
68-
}
6971

70-
bintray {
71-
user = properties.getProperty("bintray.user")
72-
key = properties.getProperty("bintray.apiKey")
73-
74-
configurations = ['archives']
75-
pkg {
76-
repo = "maven"
77-
userOrg = 'servicestack'
78-
name = "ServiceStack.Client"
79-
websiteUrl = siteUrl
80-
vcsUrl = gitUrl
81-
licenses = ["BSD 3-Clause"]
82-
publish = properties.getProperty('bintray.publish') == 'true'
72+
repositories {
73+
maven {
74+
name = 'OSSRH'
75+
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
76+
credentials {
77+
username = project.findProperty("ossrhUsername") ?: System.getenv("OSSRH_USERNAME")
78+
password = project.findProperty("ossrhPassword") ?: System.getenv("OSSRH_TOKEN")
79+
}
80+
}
81+
maven {
82+
url = uri("file://${project.rootDir}/localRepo")
83+
}
8384
}
8485
}
8586

86-
task sourcesJar(type: Jar, dependsOn: classes) {
87-
classifier = 'sources'
88-
from sourceSets.main.allSource
89-
}
90-
91-
task javadocJar(type: Jar, dependsOn: javadoc) {
92-
classifier = 'javadoc'
93-
from javadoc.destinationDir
94-
}
95-
96-
artifacts {
97-
archives sourcesJar
98-
archives javadocJar
87+
java {
88+
sourceCompatibility = JavaVersion.VERSION_1_8
89+
targetCompatibility = JavaVersion.VERSION_1_8
9990
}

0 commit comments

Comments
 (0)