diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index fdce5fb66..bbf81769c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -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)" \ diff --git a/build.gradle b/build.gradle index 26cb3fcdf..e83fa2986 100644 --- a/build.gradle +++ b/build.gradle @@ -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 @@ -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 { @@ -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) { - classifier = 'tests' - from sourceSets.test.output - } - - task testSourcesJar(type: Jar) { - classifier = 'test-sources' - from sourceSets.test.allSource - } } diff --git a/core/archive.gradle b/core/archive.gradle index 5add5828f..0384c844b 100644 --- a/core/archive.gradle +++ b/core/archive.gradle @@ -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 'hiroyuki.yamada@scalar-labs.com' + id = 'hiroyuki' + name = 'Hiroyuki Yamada' + email = 'hiroyuki.yamada@scalar-labs.com' } developer { - id 'brfrn169' - name 'Toshihiro Suzuki' - email 'brfrn169@gmail.com' + id = 'brfrn169' + name = 'Toshihiro Suzuki' + email = 'brfrn169@gmail.com' } } + 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 } diff --git a/core/build.gradle b/core/build.gradle index 62d4579c5..c9222cdd6 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -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) { @@ -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 { @@ -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' } diff --git a/rpc/archive.gradle b/rpc/archive.gradle index be1698eaf..5b9b28e08 100644 --- a/rpc/archive.gradle +++ b/rpc/archive.gradle @@ -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 'hiroyuki.yamada@scalar-labs.com' + id = 'hiroyuki' + name = 'Hiroyuki Yamada' + email = 'hiroyuki.yamada@scalar-labs.com' } developer { - id 'brfrn169' - name 'Toshihiro Suzuki' - email 'brfrn169@gmail.com' + id = 'brfrn169' + name = 'Toshihiro Suzuki' + email = 'brfrn169@gmail.com' } } + 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 } diff --git a/rpc/build.gradle b/rpc/build.gradle index 5f6208fa9..f66217f49 100644 --- a/rpc/build.gradle +++ b/rpc/build.gradle @@ -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' } diff --git a/server/archive.gradle b/server/archive.gradle index ee22f9fdc..f3e164d39 100644 --- a/server/archive.gradle +++ b/server/archive.gradle @@ -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 Server' - packaging 'jar' - // optionally artifactId can be defined here - description 'Scalar DB Server that is the gRPC interfarce of Scalar DB' - 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-server' + from components.java + pom { + name = 'Scalar DB Server' + description = 'Scalar DB Server that is the gRPC interfarce of Scalar DB' + 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 'hiroyuki.yamada@scalar-labs.com' + id = 'hiroyuki' + name = 'Hiroyuki Yamada' + email = 'hiroyuki.yamada@scalar-labs.com' } developer { - id 'brfrn169' - name 'Toshihiro Suzuki' - email 'brfrn169@gmail.com' + id = 'brfrn169' + name = 'Toshihiro Suzuki' + email = 'brfrn169@gmail.com' } } + 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 } diff --git a/server/build.gradle b/server/build.gradle index 91821efd4..4cd79815f 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -38,7 +38,11 @@ dependencies { implementation group: 'io.prometheus', name: 'simpleclient_dropwizard', version: '0.11.0' implementation group: 'io.prometheus', name: 'simpleclient_servlet', version: '0.11.0' implementation group: 'org.eclipse.jetty', name: 'jetty-servlet', version: '9.4.43.v20210629' - testImplementation project(':core').sourceSets.integrationTest.output + 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' + integrationTestScalarDbServerImplementation project(':core').sourceSets.integrationTest.output } application { @@ -59,9 +63,6 @@ task integrationTestScalarDbServer(type: Test) { outputs.upToDateWhen { false } // ensures integration tests are run every time when called } -// build should not depend on the integration tests -check.dependsOn -= integrationTestScalarDbServer - spotless { java { target 'src/*/java/**/*.java' @@ -85,6 +86,6 @@ distTar { // 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' }