Skip to content

Commit e1d4036

Browse files
Merge branch 'release-2.9.1'
2 parents a8d62b4 + 3d36275 commit e1d4036

File tree

17 files changed

+237
-269
lines changed

17 files changed

+237
-269
lines changed

Jenkinsfile

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,16 @@ boolean isPublish = BRANCH_NAME == 'publish'
77
String versionPostfix = isPublish ? '' : BRANCH_NAME // Build script detects empty string as not set.
88

99
// Note: using single quotes to avoid Groovy String interpolation leaking secrets.
10-
def internalRepoArgs = '-PinternalObjectBoxRepo=$MVN_REPO_URL ' +
11-
'-PinternalObjectBoxRepoUser=$MVN_REPO_LOGIN_USR ' +
12-
'-PinternalObjectBoxRepoPassword=$MVN_REPO_LOGIN_PSW'
13-
def uploadRepoArgs = '-PpreferredRepo=$MVN_REPO_UPLOAD_URL ' +
14-
'-PpreferredUsername=$MVN_REPO_LOGIN_USR ' +
15-
'-PpreferredPassword=$MVN_REPO_LOGIN_PSW '
16-
// Note: add quotes around URL parameter to avoid line breaks due to semicolon in URL.
17-
def uploadRepoArgsBintray = '\"-PpreferredRepo=$BINTRAY_URL\" ' +
18-
'-PpreferredUsername=$BINTRAY_LOGIN_USR ' +
19-
'-PpreferredPassword=$BINTRAY_LOGIN_PSW'
10+
def gitlabRepoArgs = '-PgitlabUrl=$GITLAB_URL -PgitlabPrivateToken=$GITLAB_TOKEN'
11+
def uploadRepoArgsCentral = '-PsonatypeUsername=$OSSRH_LOGIN_USR -PsonatypePassword=$OSSRH_LOGIN_PSW'
2012

2113
// https://jenkins.io/doc/book/pipeline/syntax/
2214
pipeline {
2315
agent { label 'java' }
2416

2517
environment {
26-
MVN_REPO_LOGIN = credentials('objectbox_internal_mvn_user')
27-
MVN_REPO_URL = credentials('objectbox_internal_mvn_repo_http')
28-
MVN_REPO_UPLOAD_URL = credentials('objectbox_internal_mvn_repo')
18+
GITLAB_URL = credentials('gitlab_url')
19+
GITLAB_TOKEN = credentials('GITLAB_TOKEN_ALL')
2920
// Note: for key use Jenkins secret file with PGP key as text in ASCII-armored format.
3021
ORG_GRADLE_PROJECT_signingKeyFile = credentials('objectbox_signing_key')
3122
ORG_GRADLE_PROJECT_signingKeyId = credentials('objectbox_signing_key_id')
@@ -58,7 +49,7 @@ pipeline {
5849

5950
stage('build-java') {
6051
steps {
61-
sh "./ci/test-with-asan.sh $gradleArgs $internalRepoArgs -Dextensive-tests=true clean test " +
52+
sh "./ci/test-with-asan.sh $gradleArgs $gitlabRepoArgs -Dextensive-tests=true clean test " +
6253
"--tests io.objectbox.FunctionalTestSuite " +
6354
"--tests io.objectbox.test.proguard.ObfuscatedEntityTest " +
6455
"--tests io.objectbox.rx.QueryObserverTest " +
@@ -69,25 +60,24 @@ pipeline {
6960

7061
stage('upload-to-internal') {
7162
steps {
72-
sh "./gradlew $gradleArgs $internalRepoArgs $uploadRepoArgs -PversionPostFix=$versionPostfix uploadArchives"
63+
sh "./gradlew $gradleArgs $gitlabRepoArgs -PversionPostFix=$versionPostfix publishMavenJavaPublicationToGitLabRepository"
7364
}
7465
}
7566

76-
stage('upload-to-bintray') {
67+
stage('upload-to-central') {
7768
when { expression { return isPublish } }
7869
environment {
79-
BINTRAY_URL = credentials('bintray_url')
80-
BINTRAY_LOGIN = credentials('bintray_login')
70+
OSSRH_LOGIN = credentials('ossrh-login')
8171
}
8272
steps {
8373
googlechatnotification url: 'id:gchat_java',
84-
message: "*Publishing* ${currentBuild.fullDisplayName} to Bintray...\n${env.BUILD_URL}"
74+
message: "*Publishing* ${currentBuild.fullDisplayName} to Central...\n${env.BUILD_URL}"
8575

8676
// Note: supply internal repo as tests use native dependencies that might not be published, yet.
87-
sh "./gradlew $gradleArgs $internalRepoArgs $uploadRepoArgsBintray uploadArchives"
77+
sh "./gradlew $gradleArgs $gitlabRepoArgs $uploadRepoArgsCentral publishMavenJavaPublicationToSonatypeRepository closeAndReleaseStagingRepository"
8878

8979
googlechatnotification url: 'id:gchat_java',
90-
message: "Published ${currentBuild.fullDisplayName} successfully to Bintray - check https://bintray.com/objectbox/objectbox\n${env.BUILD_URL}"
80+
message: "Published ${currentBuild.fullDisplayName} successfully to Central - check https://repo1.maven.org/maven2/io/objectbox/ in a few minutes.\n${env.BUILD_URL}"
9181
}
9282
}
9383

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
ObjectBox is a superfast object-oriented database with strong relation support.
77
ObjectBox is embedded into your Android, Linux, macOS, or Windows app.
88

9-
**Latest version: [2.9.0 (2021/02/16)](https://docs.objectbox.io/#objectbox-changelog)**
9+
**Latest version: [2.9.1 (2021/03/15)](https://docs.objectbox.io/#objectbox-changelog)**
1010

1111
Demo code using ObjectBox:
1212

@@ -33,7 +33,7 @@ Add this to your root build.gradle (project level):
3333

3434
```groovy
3535
buildscript {
36-
ext.objectboxVersion = '2.9.0'
36+
ext.objectboxVersion = '2.9.1'
3737
dependencies {
3838
classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
3939
}

build.gradle

Lines changed: 77 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
buildscript {
22
ext {
33
// Typically, only edit those two:
4-
def objectboxVersionNumber = '2.9.0' // without "-SNAPSHOT", e.g. '2.5.0' or '2.4.0-RC'
4+
def objectboxVersionNumber = '2.9.1' // without "-SNAPSHOT", e.g. '2.5.0' or '2.4.0-RC'
55
def objectboxVersionRelease = true // set to true for releasing to ignore versionPostFix to avoid e.g. "-dev" versions
66

77
// version post fix: '-<value>' or '' if not defined; e.g. used by CI to pass in branch name
@@ -42,6 +42,7 @@ buildscript {
4242
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
4343
// https://github.com/spotbugs/spotbugs-gradle-plugin/releases
4444
classpath "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.5.1"
45+
classpath "io.github.gradle-nexus:publish-plugin:1.0.0"
4546
}
4647
}
4748

@@ -82,108 +83,97 @@ def hasSigningProperties() {
8283
}
8384

8485
configure(subprojects.findAll { projectNamesToPublish.contains(it.name) }) {
85-
apply plugin: 'maven'
86+
apply plugin: 'maven-publish'
8687
apply plugin: 'signing'
8788

88-
configurations {
89-
deployerJars
90-
}
89+
publishing {
90+
repositories {
91+
maven {
92+
name = 'GitLab'
93+
if (project.hasProperty('gitlabUrl') && project.hasProperty('gitlabPrivateToken')) {
94+
// "https://gitlab.example.com/api/v4/projects/<PROJECT_ID>/packages/maven"
95+
url = "$gitlabUrl/api/v4/projects/14/packages/maven"
96+
println "GitLab repository set to $url."
97+
98+
credentials(HttpHeaderCredentials) {
99+
name = "Private-Token"
100+
value = gitlabPrivateToken
101+
}
102+
authentication {
103+
header(HttpHeaderAuthentication)
104+
}
105+
} else {
106+
println "WARNING: Can not publish to GitLab: gitlabUrl or gitlabPrivateToken not set."
107+
}
108+
}
109+
// Note: Sonatype repo created by publish-plugin.
110+
}
91111

92-
dependencies {
93-
// Using an older version to remain compatible with Wagon API used by Gradle/Maven
94-
deployerJars 'org.apache.maven.wagon:wagon-webdav-jackrabbit:3.2.0'
95-
deployerJars 'org.apache.maven.wagon:wagon-ftp:3.3.2'
112+
publications {
113+
mavenJava(MavenPublication) {
114+
// Note: Projects set additional specific properties.
115+
pom {
116+
packaging = 'jar'
117+
url = 'https://objectbox.io'
118+
licenses {
119+
license {
120+
name = 'The Apache Software License, Version 2.0'
121+
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
122+
distribution = 'repo'
123+
}
124+
}
125+
developers {
126+
developer {
127+
id = 'ObjectBox'
128+
name = 'ObjectBox'
129+
}
130+
}
131+
issueManagement {
132+
system = 'GitHub Issues'
133+
url = 'https://github.com/objectbox/objectbox-java/issues'
134+
}
135+
organization {
136+
name = 'ObjectBox Ltd.'
137+
url = 'https://objectbox.io'
138+
}
139+
scm {
140+
connection = 'scm:[email protected]:objectbox/objectbox-java.git'
141+
developerConnection = 'scm:[email protected]:objectbox/objectbox-java.git'
142+
url = 'https://github.com/objectbox/objectbox-java'
143+
}
144+
}
145+
}
146+
}
96147
}
97148

98149
signing {
99150
if (hasSigningProperties()) {
100151
String signingKey = new File(signingKeyFile).text
101152
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
102-
sign configurations.archives
153+
sign publishing.publications.mavenJava
103154
} else {
104155
println "Signing information missing/incomplete for ${project.name}"
105156
}
106157
}
158+
}
107159

108-
// Use afterEvaluate or all dependencies will be lost in the generated POM
109-
afterEvaluate {
110-
uploadArchives {
111-
repositories {
112-
mavenDeployer {
113-
def preferredRepo = project.findProperty('preferredRepo')
114-
println "preferredRepo=$preferredRepo"
115-
116-
if (preferredRepo == 'local') {
117-
repository url: repositories.mavenLocal().url
118-
println "uploadArchives repo is mavenLocal()."
119-
} else if (preferredRepo != null
120-
&& project.hasProperty('preferredUsername')
121-
&& project.hasProperty('preferredPassword')) {
122-
if (!hasSigningProperties()) {
123-
throw new InvalidUserDataException("To upload to repo signing is required.")
124-
}
125-
126-
configuration = configurations.deployerJars
127-
128-
// replace placeholders
129-
def repositoryUrl = preferredRepo
130-
.replace('__groupId__', project.group)
131-
.replace('__artifactId__', project.archivesBaseName)
132-
repository(url: repositoryUrl) {
133-
authentication(userName: preferredUsername, password: preferredPassword)
134-
}
135-
136-
println "uploadArchives repo is $repositoryUrl."
137-
} else if (project.hasProperty('sonatypeUsername')
138-
&& project.hasProperty('sonatypePassword')) {
139-
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
140-
141-
def isSnapshot = version.endsWith('-SNAPSHOT')
142-
def sonatypeRepositoryUrl = isSnapshot
143-
? "https://oss.sonatype.org/content/repositories/snapshots/"
144-
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
145-
repository(url: sonatypeRepositoryUrl) {
146-
authentication(userName: sonatypeUsername, password: sonatypePassword)
147-
}
148-
149-
println "uploadArchives repo is $sonatypeRepositoryUrl."
150-
} else {
151-
println "WARNING: uploadArchives settings incomplete, can not upload archives."
152-
}
153-
154-
pom.project {
155-
packaging 'jar'
156-
url 'https://objectbox.io'
157-
158-
scm {
159-
url 'https://github.com/objectbox/objectbox-java'
160-
connection 'scm:[email protected]:objectbox/objectbox-java.git'
161-
developerConnection 'scm:[email protected]:objectbox/objectbox-java.git'
162-
}
163-
164-
developers {
165-
developer {
166-
id 'ObjectBox'
167-
name 'ObjectBox'
168-
}
169-
}
170-
171-
issueManagement {
172-
system 'GitHub Issues'
173-
url 'https://github.com/objectbox/objectbox-java/issues'
174-
}
160+
wrapper {
161+
distributionType = Wrapper.DistributionType.ALL
162+
}
175163

176-
organization {
177-
name 'ObjectBox Ltd.'
178-
url 'https://objectbox.io'
179-
}
180-
}
181-
}
164+
// Plugin to publish to Central https://github.com/gradle-nexus/publish-plugin/
165+
// This plugin ensures a separate, named staging repo is created for each build when publishing.
166+
apply plugin: "io.github.gradle-nexus.publish-plugin"
167+
nexusPublishing {
168+
repositories {
169+
sonatype {
170+
if (project.hasProperty("sonatypeUsername") && project.hasProperty("sonatypePassword")) {
171+
println('nexusPublishing credentials supplied.')
172+
username = sonatypeUsername
173+
password = sonatypePassword
174+
} else {
175+
println('nexusPublishing credentials NOT supplied.')
182176
}
183177
}
184178
}
185179
}
186-
187-
wrapper {
188-
distributionType = Wrapper.DistributionType.ALL
189-
}

ci/Jenkinsfile-Windows

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@ String gradleArgs = '-Dorg.gradle.daemon=false --stacktrace'
66
boolean isPublish = BRANCH_NAME == 'publish'
77

88
// Note: using single quotes to avoid Groovy String interpolation leaking secrets.
9-
def internalRepoArgsBat = '-PinternalObjectBoxRepo=%MVN_REPO_URL% ' +
10-
'-PinternalObjectBoxRepoUser=%MVN_REPO_LOGIN_USR% ' +
11-
'-PinternalObjectBoxRepoPassword=%MVN_REPO_LOGIN_PSW%'
9+
def gitlabRepoArgsBat = '-PgitlabUrl=%GITLAB_URL% -PgitlabPrivateToken=%GITLAB_TOKEN%'
1210

1311
// https://jenkins.io/doc/book/pipeline/syntax/
1412
pipeline {
1513
agent { label 'windows' }
1614

1715
environment {
18-
MVN_REPO_URL = credentials('objectbox_internal_mvn_repo_http')
19-
MVN_REPO_LOGIN = credentials('objectbox_internal_mvn_user')
16+
GITLAB_URL = credentials('gitlab_url')
17+
GITLAB_TOKEN = credentials('GITLAB_TOKEN_ALL')
2018
}
2119

2220
options {
@@ -41,7 +39,7 @@ pipeline {
4139
// Remove files to avoid archiving them again.
4240
bat 'del /q /s hs_err_pid*.log'
4341

44-
bat "gradlew $gradleArgs $internalRepoArgsBat cleanTest build test"
42+
bat "gradlew $gradleArgs $gitlabRepoArgsBat cleanTest build test"
4543
}
4644
post {
4745
always {
@@ -60,7 +58,7 @@ pipeline {
6058
// 32-bit ObjectBox to run tests (see build.gradle file).
6159
// Note: assumes JAVA_HOME_X86 is set to 32-bit JDK path.
6260
// Note: no space before && or value has space as well.
63-
bat "set TEST_WITH_JAVA_X86=true&& gradlew $gradleArgs $internalRepoArgsBat cleanTest build test"
61+
bat "set TEST_WITH_JAVA_X86=true&& gradlew $gradleArgs $gitlabRepoArgsBat cleanTest build test"
6462
}
6563
post {
6664
always {
@@ -73,7 +71,7 @@ pipeline {
7371
stage('package-javadoc-for-web') {
7472
when { expression { return isPublish } }
7573
steps {
76-
bat "gradlew $gradleArgs $internalRepoArgsBat :objectbox-java:packageJavadocForWeb"
74+
bat "gradlew $gradleArgs $gitlabRepoArgsBat :objectbox-java:packageJavadocForWeb"
7775
}
7876
post {
7977
always {

objectbox-java-api/build.gradle

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,15 @@ task sourcesJar(type: Jar) {
1313
archiveClassifier.set('sources')
1414
}
1515

16-
artifacts {
17-
// java plugin adds jar.
18-
archives javadocJar
19-
archives sourcesJar
20-
}
21-
22-
uploadArchives {
23-
repositories {
24-
mavenDeployer {
25-
// Basic definitions are defined in root project
26-
pom.project {
27-
name 'ObjectBox API'
28-
description 'ObjectBox is a fast NoSQL database for Objects'
29-
30-
licenses {
31-
license {
32-
name 'The Apache Software License, Version 2.0'
33-
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
34-
distribution 'repo'
35-
}
36-
}
37-
}
16+
// Set project-specific properties.
17+
publishing.publications {
18+
mavenJava(MavenPublication) {
19+
from components.java
20+
artifact sourcesJar
21+
artifact javadocJar
22+
pom {
23+
name = 'ObjectBox API'
24+
description = 'ObjectBox is a fast NoSQL database for Objects'
3825
}
3926
}
40-
}
27+
}

0 commit comments

Comments
 (0)