diff --git a/dependencies.gradle b/dependencies.gradle index fe857e7..bf10907 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,10 +1,10 @@ ext { - kotlin_version = '1.2.41' - protobufPluginVersion = '0.8.4' - protocVersion = '3.5.1' + kotlin_version = '1.3.72' + protobufPluginVersion = '0.8.17' + protocVersion = '3.6.1' kotlinPlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - prtobufPlugin = "com.google.protobuf:protobuf-gradle-plugin:$protobufPluginVersion" + protobufPlugin = "com.google.protobuf:protobuf-gradle-plugin:$protobufPluginVersion" junitPlugin = 'org.junit.platform:junit-platform-gradle-plugin:1.1.0' diff --git a/gradle/gradle-mvn-push.gradle b/gradle/gradle-mvn-push.gradle index 00eaf0a..d01a758 100644 --- a/gradle/gradle-mvn-push.gradle +++ b/gradle/gradle-mvn-push.gradle @@ -1,82 +1,148 @@ -apply plugin: 'maven' +/* + * Copyright 2013 Chris Banes + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +apply plugin: 'maven-publish' apply plugin: 'signing' +version = VERSION_NAME +group = GROUP + def isReleaseBuild() { return VERSION_NAME.contains("SNAPSHOT") == false } +def getReleaseRepositoryUrl() { + return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL + : "https://oss.sonatype.org/service/local/staging/deploy/maven2/" +} + +def getSnapshotRepositoryUrl() { + return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL + : "https://oss.sonatype.org/content/repositories/snapshots/" +} + def getRepositoryUsername() { - return hasProperty('ossrhUsername') ? ossrhUsername : "" + return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : "" } def getRepositoryPassword() { - return hasProperty('ossrhPassword') ? ossrhPassword : "" + return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : "" } -afterEvaluate { project -> - uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } +def configurePom(pom) { + pom.name = POM_NAME + pom.packaging = POM_PACKAGING + pom.description = POM_DESCRIPTION + pom.url = POM_URL - pom.groupId = GROUP - pom.artifactId = POM_ARTIFACT_ID - pom.version = VERSION_NAME + pom.scm { + url = POM_SCM_URL + connection = POM_SCM_CONNECTION + developerConnection = POM_SCM_DEV_CONNECTION + } - repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) - } - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { - authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) - } + pom.licenses { + license { + name = POM_LICENCE_NAME + url = POM_LICENCE_URL + distribution = POM_LICENCE_DIST + } + } + + pom.developers { + developer { + id = POM_DEVELOPER_ID + name = POM_DEVELOPER_NAME + } + } +} + +afterEvaluate { project -> + publishing { + repositories { + maven { + def releasesRepoUrl = getReleaseRepositoryUrl() + def snapshotsRepoUrl = getSnapshotRepositoryUrl() + url = isReleaseBuild() ? releasesRepoUrl : snapshotsRepoUrl - pom.project { - name POM_NAME - packaging POM_PACKAGING - description POM_DESCRIPTION - url POM_URL - - scm { - url POM_SCM_URL - connection POM_SCM_CONNECTION - developerConnection POM_SCM_DEV_CONNECTION - } - - licenses { - license { - name POM_LICENCE_NAME - url POM_LICENCE_URL - distribution POM_LICENCE_DIST - } - } - - developers { - developer { - id POM_DEVELOPER_ID - name POM_DEVELOPER_NAME - } - } + credentials(PasswordCredentials) { + username = getRepositoryUsername() + password = getRepositoryPassword() } } } } - signing { - required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") } - sign configurations.archives + if (project.getPlugins().hasPlugin('com.android.application') || + project.getPlugins().hasPlugin('com.android.library')) { + + task androidJavadocs(type: Javadoc) { + source = android.sourceSets.main.java.source + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + excludes = ['**/*.kt'] + } + + task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { + classifier = 'javadoc' + from androidJavadocs.destinationDir + } + + task androidSourcesJar(type: Jar) { + classifier = 'sources' + from android.sourceSets.main.java.source + } } - task javadocJar(type: Jar) { - classifier = 'javadoc' - from javadoc + if (JavaVersion.current().isJava8Compatible()) { + allprojects { + tasks.withType(Javadoc) { + options.addStringOption('Xdoclint:none', '-quiet') + } + } } - task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource + if (JavaVersion.current().isJava9Compatible()) { + allprojects { + tasks.withType(Javadoc) { + options.addBooleanOption('html5', true) + } + } } artifacts { - archives sourcesJar, javadocJar + if (project.getPlugins().hasPlugin('com.android.application') || + project.getPlugins().hasPlugin('com.android.library')) { + archives androidSourcesJar + archives androidJavadocsJar + } + } + + publishing.publications.all { publication -> + publication.groupId = GROUP + publication.version = VERSION_NAME + + publication.artifact androidSourcesJar + publication.artifact androidJavadocsJar + + configurePom(publication.pom) + } + + signing { + publishing.publications.all { publication -> + sign publication + } } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 933b647..6b7fd26 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip diff --git a/kotlin-protobuf-bson-codec/build.gradle b/kotlin-protobuf-bson-codec/build.gradle index 49d4bdc..6c6e02b 100644 --- a/kotlin-protobuf-bson-codec/build.gradle +++ b/kotlin-protobuf-bson-codec/build.gradle @@ -1,15 +1,15 @@ buildscript { ext { - kotlin_version = '1.2.41' - protobufPluginVersion = '0.8.4' - protocVersion = '3.5.1' + kotlin_version = '1.3.72' + protobufPluginVersion = '0.8.17' + protocVersion = '3.6.1' } repositories { mavenCentral() } dependencies { classpath rootProject.ext.kotlinPlugin - classpath rootProject.ext.prtobufPlugin + classpath rootProject.ext.protobufPlugin classpath rootProject.ext.junitPlugin } } @@ -21,14 +21,15 @@ apply plugin: 'kotlin' apply plugin: 'com.google.protobuf' apply plugin: 'org.junit.platform.gradle.plugin' -sourceCompatibility = 1.8 +sourceCompatibility = JavaVersion.VERSION_1_8 +targetCompatibility = JavaVersion.VERSION_1_8 repositories { mavenCentral() } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" // protobuf compile "com.google.protobuf:protobuf-java:$protocVersion" @@ -38,10 +39,9 @@ dependencies { compile 'org.mongodb:bson:3.6.3' // KMongo - testCompile 'org.litote.kmongo:kmongo-coroutine:3.6.2' - testCompile 'io.kotlintest:kotlintest-runner-junit5:3.0.4' - testCompile "org.jetbrains.kotlinx:kotlinx-coroutines-core:0.22.3" - + testCompile 'org.litote.kmongo:kmongo-coroutine:3.12.2' + testCompile 'io.kotest:kotest-runner-junit5:4.1.3' + testCompile "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8" } @@ -72,6 +72,5 @@ compileTestKotlin { kotlinOptions.jvmTarget = "1.8" } -kotlin.experimental.coroutines 'enable' apply from: rootProject.file('gradle/gradle-mvn-push.gradle') \ No newline at end of file diff --git a/kotlin-protobuf-bson-codec/src/test/kotlin/io.github.gaplotech/MongoCamelCasePBSpec.kt b/kotlin-protobuf-bson-codec/src/test/kotlin/io.github.gaplotech/MongoCamelCasePBSpec.kt index 63b2e5f..f1dcbf8 100644 --- a/kotlin-protobuf-bson-codec/src/test/kotlin/io.github.gaplotech/MongoCamelCasePBSpec.kt +++ b/kotlin-protobuf-bson-codec/src/test/kotlin/io.github.gaplotech/MongoCamelCasePBSpec.kt @@ -1,9 +1,9 @@ import com.mongodb.async.client.MongoCollection import io.github.gaplotech.pb.Test.CamelCase import io.github.gaplotech.repository.MongoPBRepository -import io.kotlintest.shouldBe -import io.kotlintest.specs.FeatureSpec -import kotlinx.coroutines.experimental.runBlocking +import io.kotest.matchers.shouldBe +import io.kotest.core.spec.style.FeatureSpec +import kotlinx.coroutines.runBlocking import org.litote.kmongo.coroutine.findOne import org.litote.kmongo.coroutine.getCollectionOfName import org.litote.kmongo.coroutine.insertOne diff --git a/kotlin-protobuf-bson-codec/src/test/kotlin/io.github.gaplotech/MongoMyTestPBSpec.kt b/kotlin-protobuf-bson-codec/src/test/kotlin/io.github.gaplotech/MongoMyTestPBSpec.kt index f7bef3d..1245f93 100644 --- a/kotlin-protobuf-bson-codec/src/test/kotlin/io.github.gaplotech/MongoMyTestPBSpec.kt +++ b/kotlin-protobuf-bson-codec/src/test/kotlin/io.github.gaplotech/MongoMyTestPBSpec.kt @@ -2,9 +2,9 @@ import com.google.protobuf.ByteString import io.github.gaplotech.pb.Test.MyEnumV3 import io.github.gaplotech.pb.Test.MyTestV3 import io.github.gaplotech.repository.MongoPBRepository -import io.kotlintest.shouldBe -import io.kotlintest.specs.FeatureSpec -import kotlinx.coroutines.experimental.runBlocking +import io.kotest.matchers.shouldBe +import io.kotest.core.spec.style.FeatureSpec +import kotlinx.coroutines.runBlocking import org.litote.kmongo.coroutine.findOne import org.litote.kmongo.coroutine.getCollectionOfName import org.litote.kmongo.coroutine.insertOne diff --git a/kotlin-protobuf-bson-codec/src/test/kotlin/io.github.gaplotech/MongoMyTestSpecialPBSpec.kt b/kotlin-protobuf-bson-codec/src/test/kotlin/io.github.gaplotech/MongoMyTestSpecialPBSpec.kt index bdb2f57..ffe00f0 100644 --- a/kotlin-protobuf-bson-codec/src/test/kotlin/io.github.gaplotech/MongoMyTestSpecialPBSpec.kt +++ b/kotlin-protobuf-bson-codec/src/test/kotlin/io.github.gaplotech/MongoMyTestSpecialPBSpec.kt @@ -4,9 +4,9 @@ import com.mongodb.async.client.MongoCollection import io.github.gaplotech.pb.Test.MyTestSpecial import io.github.gaplotech.pb.Test.MyTestV3 import io.github.gaplotech.repository.MongoPBRepository -import io.kotlintest.shouldBe -import io.kotlintest.specs.FeatureSpec -import kotlinx.coroutines.experimental.runBlocking +import io.kotest.matchers.shouldBe +import io.kotest.core.spec.style.FeatureSpec +import kotlinx.coroutines.runBlocking import org.litote.kmongo.coroutine.findOne import org.litote.kmongo.coroutine.getCollectionOfName import org.litote.kmongo.coroutine.insertOne diff --git a/pbmongo-async/build.gradle b/pbmongo-async/build.gradle index ffdefd9..872b205 100644 --- a/pbmongo-async/build.gradle +++ b/pbmongo-async/build.gradle @@ -4,7 +4,7 @@ buildscript { } dependencies { classpath rootProject.ext.kotlinPlugin - classpath rootProject.ext.prtobufPlugin + classpath rootProject.ext.protobufPlugin } } @@ -12,14 +12,15 @@ apply plugin: 'java' apply plugin: 'kotlin' apply plugin: 'com.google.protobuf' -sourceCompatibility = 1.8 +sourceCompatibility = JavaVersion.VERSION_1_8 +targetCompatibility = JavaVersion.VERSION_1_8 repositories { mavenCentral() } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" testCompile group: 'junit', name: 'junit', version: '4.12' compile project(':kotlin-protobuf-bson-codec') @@ -30,9 +31,9 @@ dependencies { compile "com.google.protobuf:protobuf-java-util:$protocVersion" // KMongo - testCompile 'org.litote.kmongo:kmongo-coroutine:3.6.2' - testCompile 'io.kotlintest:kotlintest-runner-junit5:3.0.4' - testCompile "org.jetbrains.kotlinx:kotlinx-coroutines-core:0.22.3" + testCompile 'org.litote.kmongo:kmongo-coroutine:3.12.2' + testCompile 'io.kotest:kotest-runner-junit5-jvm:4.1.3' + testCompile 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8' } compileKotlin { @@ -57,6 +58,4 @@ protobuf { } } -kotlin.experimental.coroutines 'enable' - apply from: rootProject.file('gradle/gradle-mvn-push.gradle')