Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use maven-publish #258

Merged
merged 2 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ jobs:
- name: Upload scalardb, scalardb-server, and scalardb-rpc to Maven Central Repository
run: |
echo "${{secrets.SIGNING_SECRET_KEY_RING}}" | base64 -d > ~/.gradle/secring.gpg
gradle uploadArchives \
-Pversion=${{ steps.version.outputs.version }} \
gradle publish \
-Psigning.keyId="${{ secrets.SIGNING_KEY_ID }}" \
-P'signing.password'="${{ secrets.SIGNING_PASSWORD }}" \
-Psigning.secretKeyRingFile="$(echo ~/.gradle/secring.gpg)" \
Expand Down
35 changes: 8 additions & 27 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ subprojects {
mavenCentral()
}

dependencies {
testImplementation group: 'junit', name: 'junit', version: '4.12'
testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.9.1'
testImplementation group: 'org.mockito', name: 'mockito-core', version: '2.16.0'
testImplementation group: 'org.mockito', name: 'mockito-inline', version: '2.16.0'
}

test {
maxHeapSize "512m"
testLogging.showStandardStreams = true
Expand All @@ -39,8 +32,16 @@ subprojects {
sourceCompatibility = 1.8
targetCompatibility = 1.8

java {
withJavadocJar()
withSourcesJar()
}

javadoc {
options.addStringOption("notimestamp", "com.scalar.db")
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}

distZip {
Expand All @@ -54,24 +55,4 @@ subprojects {
installDist {
duplicatesStrategy DuplicatesStrategy.EXCLUDE
}

task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}

task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}

task testJar(type: Jar) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just curious. Any reason you decided not to publish test and testSources?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including test and testSources jars to a release artifact seems to be a bit tricky in the maven-publish plugin. And I rethought why we needed to publish them, and I thought we didn't need to do that, at least for now.

What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine not to have them since we don't really use them.
Thank you!

classifier = 'tests'
from sourceSets.test.output
}

task testSourcesJar(type: Jar) {
classifier = 'test-sources'
from sourceSets.test.allSource
}
}
88 changes: 38 additions & 50 deletions core/archive.gradle
Original file line number Diff line number Diff line change
@@ -1,66 +1,54 @@
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'signing'

artifacts {
archives javadocJar, sourcesJar, testJar, testSourcesJar
}

signing {
sign configurations.archives
}

configurations.archives.artifacts.removeAll {
// exclude from the archives configuration all artifacts that were generated by distZip & distTar
def depTasks = it.getBuildDependencies().getDependencies()
depTasks.contains(distZip) || depTasks.contains(distTar)
}

uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}

snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}

pom.project {
name 'Scalar DB'
packaging 'jar'
// optionally artifactId can be defined here
description 'A library that makes non-ACID distributed databases/storages ACID-compliant.'
url 'https://github.com/scalar-labs/scalardb'

scm {
connection 'scm:git:https://github.com/scalar-labs/scalardb.git'
developerConnection 'scm:git:https://github.com/scalar-labs/scalardb.git'
url 'https://github.com/scalar-labs/scalardb'
}

publishing {
publications {
mavenJava(MavenPublication) {
artifactId = 'scalardb'
from components.java
pom {
name = 'Scalar DB'
description = 'A library that makes non-ACID distributed databases/storages ACID-compliant'
url = 'https://github.com/scalar-labs/scalardb'
licenses {
license {
name 'Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0'
name = 'Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0'
}
}

developers {
developer {
id 'hiroyuki'
name 'Hiroyuki Yamada'
email '[email protected]'
id = 'hiroyuki'
name = 'Hiroyuki Yamada'
email = '[email protected]'
}
developer {
id 'brfrn169'
name 'Toshihiro Suzuki'
email '[email protected]'
id = 'brfrn169'
name = 'Toshihiro Suzuki'
email = '[email protected]'
}
}
scm {
connection = 'scm:git:https://github.com/scalar-labs/scalardb.git'
developerConnection = 'scm:git:https://github.com/scalar-labs/scalardb.git'
url = 'https://github.com/scalar-labs/scalardb'
}
}
}
}
repositories {
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = "${ossrhUsername}"
password = "${ossrhPassword}"
}
}
}
}

signing {
sign publishing.publications.mavenJava
}
15 changes: 6 additions & 9 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ dependencies {
implementation group: 'org.postgresql', name: 'postgresql', version: '42.2.18'
implementation group: 'com.oracle.database.jdbc', name: 'ojdbc8-production', version: '19.8.0.0'
implementation group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: '8.4.1.jre8'
testImplementation group: 'junit', name: 'junit', version: '4.12'
testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.9.1'
testImplementation group: 'org.mockito', name: 'mockito-core', version: '2.16.0'
testImplementation group: 'org.mockito', name: 'mockito-inline', version: '2.16.0'
}

task integrationTestCassandra(type: Test) {
Expand Down Expand Up @@ -154,19 +158,12 @@ task integrationTestMultiStorage(type: Test) {
outputs.upToDateWhen { false } // ensures integration tests are run every time when called
}

// build should not depend on the integration tests
check.dependsOn -= integrationTestCassandra
check.dependsOn -= integrationTestCosmos
check.dependsOn -= integrationTestDynamo
check.dependsOn -= integrationTestJdbc
check.dependsOn -= integrationTestMultiStorage

task copyDependencies(type: Copy) {
configurations.api.canBeResolved true
configurations.implementation.canBeResolved true
from(configurations.api + configurations.implementation)
into file("$buildDir/libs")
duplicatesStrategy 'exclude'
duplicatesStrategy DuplicatesStrategy.EXCLUDE
}

spotless {
Expand All @@ -182,6 +179,6 @@ archivesBaseName = "scalardb"

// for archiving and uploading to maven central
if (!project.gradle.startParameter.taskNames.isEmpty() &&
project.gradle.startParameter.taskNames[0].endsWith('uploadArchives')) {
project.gradle.startParameter.taskNames[0].endsWith('publish')) {
apply from: 'archive.gradle'
}
88 changes: 38 additions & 50 deletions rpc/archive.gradle
Original file line number Diff line number Diff line change
@@ -1,66 +1,54 @@
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'signing'

artifacts {
archives javadocJar, sourcesJar, testJar, testSourcesJar
}

signing {
sign configurations.archives
}

configurations.archives.artifacts.removeAll {
// exclude from the archives configuration all artifacts that were generated by distZip & distTar
def depTasks = it.getBuildDependencies().getDependencies()
depTasks.contains(distZip) || depTasks.contains(distTar)
}

uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}

snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}

pom.project {
name 'Scalar DB RPC'
packaging 'jar'
// optionally artifactId can be defined here
description 'Scalar DB RPC libraries'
url 'https://github.com/scalar-labs/scalardb'

scm {
connection 'scm:git:https://github.com/scalar-labs/scalardb.git'
developerConnection 'scm:git:https://github.com/scalar-labs/scalardb.git'
url 'https://github.com/scalar-labs/scalardb'
}

publishing {
publications {
mavenJava(MavenPublication) {
artifactId = 'scalardb-rpc'
from components.java
pom {
name = 'Scalar DB RPC'
description = 'Scalar DB RPC libraries'
url = 'https://github.com/scalar-labs/scalardb'
licenses {
license {
name 'Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0'
name = 'Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0'
}
}

developers {
developer {
id 'hiroyuki'
name 'Hiroyuki Yamada'
email '[email protected]'
id = 'hiroyuki'
name = 'Hiroyuki Yamada'
email = '[email protected]'
}
developer {
id 'brfrn169'
name 'Toshihiro Suzuki'
email '[email protected]'
id = 'brfrn169'
name = 'Toshihiro Suzuki'
email = '[email protected]'
}
}
scm {
connection = 'scm:git:https://github.com/scalar-labs/scalardb.git'
developerConnection = 'scm:git:https://github.com/scalar-labs/scalardb.git'
url = 'https://github.com/scalar-labs/scalardb'
}
}
}
}
repositories {
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = "${ossrhUsername}"
password = "${ossrhPassword}"
}
}
}
}

signing {
sign publishing.publications.mavenJava
}
2 changes: 1 addition & 1 deletion rpc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ archivesBaseName = "scalardb-rpc"

// for archiving and uploading to maven central
if (!project.gradle.startParameter.taskNames.isEmpty() &&
project.gradle.startParameter.taskNames[0].endsWith('uploadArchives')) {
project.gradle.startParameter.taskNames[0].endsWith('publish')) {
apply from: 'archive.gradle'
}
Loading