From be8d170f2caab111411103aaaa0814c963e5f7ea Mon Sep 17 00:00:00 2001 From: Sumedh Wale Date: Fri, 10 Jun 2022 04:04:31 +0530 Subject: [PATCH] Switch from gradle maven plugin to maven-publish Gradle maven plugin is deprecated for quite a while, so switching to the new maven-publish. --- aqp | 2 +- build.gradle | 85 ++++++++++--------- connector/build.gradle | 24 +++--- docs/GettingStarted.md | 179 ++++++++++++++++++++++++++--------------- dtests/build.gradle | 4 +- dunit/build.gradle | 8 +- jdbc/build.gradle | 22 +++-- spark | 2 +- store | 2 +- 9 files changed, 186 insertions(+), 142 deletions(-) diff --git a/aqp b/aqp index 45ea4b1f57..86f7591d4a 160000 --- a/aqp +++ b/aqp @@ -1 +1 @@ -Subproject commit 45ea4b1f57aa6e0ab213ed4e41f0152086207660 +Subproject commit 86f7591d4a4a11813a84aed16d759687d98f1734 diff --git a/build.gradle b/build.gradle index 542b31c8c6..35c5091d59 100644 --- a/build.gradle +++ b/build.gradle @@ -65,7 +65,7 @@ allprojects { } apply plugin: 'java' - apply plugin: 'maven' + apply plugin: 'maven-publish' apply plugin: 'scalaStyle' apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'idea' @@ -818,70 +818,76 @@ subprojects { archiveClassifier.set('javadoc') from javadoc } + + ext { + publishArtifacts = [ jar, packageSources ] + } + pluginManager.withPlugin('scala') { task packageScalaDocs(type: Jar, dependsOn: scaladoc) { - classifier = 'javadoc' + archiveClassifier.set('javadoc') from scaladoc } - if (rootProject.hasProperty('enablePublish')) { - artifacts { - archives packageScalaDocs - } - } + publishArtifacts.add(packageScalaDocs) } if (rootProject.hasProperty('enablePublish')) { - artifacts { - archives packageSources - } - - signing { - useGpgCmd() - sign configurations.archives - } - - uploadArchives { + publishing { repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') { - authentication(userName: ossrhUsername, password: ossrhPassword) + 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 + name = 'SonatypeOSS' + credentials { + username = ossrhUsername + password = ossrhPassword } - snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/') { - authentication(userName: ossrhUsername, password: ossrhPassword) + } + } + publications { + maven(MavenPublication) { + from components.java + afterEvaluate { + artifactId = jar.archiveBaseName.get() + artifacts = publishArtifacts } - pom.project { - name 'SnappyData' - packaging 'jar' + pom { + name = 'SnappyData' + packaging = 'jar' // optionally artifactId can be defined here - description 'SnappyData distributed data store and execution engine' - url 'https://github.com/TIBCOSoftware/snappydata' + description = 'SnappyData distributed data store and execution engine' + url = 'https://github.com/TIBCOSoftware/snappydata' scm { - connection 'scm:git:https://github.com/TIBCOSoftware/snappydata.git' - developerConnection 'scm:git:https://github.com/TIBCOSoftware/snappydata.git' - url 'https://github.com/TIBCOSoftware/snappydata' + connection = 'scm:git:https://github.com/TIBCOSoftware/snappydata.git' + developerConnection = 'scm:git:https://github.com/TIBCOSoftware/snappydata.git' + url = 'https://github.com/TIBCOSoftware/snappydata' } licenses { license { - name 'The Apache License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' + name = 'The Apache License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' } } developers { developer { - id 'swale' - name 'Sumedh Wale' - email 'swale@tibco.com' + id = 'swale' + name = 'Sumedh Wale' + email = 'swale@tibco.com' } } } } } } + + signing { + useGpgCmd() + sign publishing.publications.maven + } } } @@ -983,17 +989,18 @@ gradle.taskGraph.whenReady { graph -> Set skipPublishFor = [ 'snappydata_' + scalaBinaryVersion, 'snappy-spark', 'snappy-store', + 'snappy-dtests_' + scalaBinaryVersion, 'snappy-compatibility-tests_' + scalaBinaryVersion, 'snappydata-native', 'snappydata-store-prebuild', 'snappy-spark-assembly_' + scalaBinaryVersion ] task publishLocal() { - dependsOn getTasksByName('install', true).findAll { + dependsOn getTasksByName('publishToMavenLocal', true).findAll { !skipPublishFor.contains(it.project.name) } } task publishMaven { - dependsOn getTasksByName('uploadArchives', true).findAll { + dependsOn getTasksByName('publish', true).findAll { !skipPublishFor.contains(it.project.name) } } diff --git a/connector/build.gradle b/connector/build.gradle index 4bf38f38af..f17d0f141c 100644 --- a/connector/build.gradle +++ b/connector/build.gradle @@ -65,20 +65,18 @@ shadowJar { } // clear dependencies from shadowJar POM -install { - repositories.mavenInstaller { - pom.whenConfigured { p -> p.dependencies.clear() } - } -} - if (rootProject.hasProperty('enablePublish')) { - artifacts { - archives shadowJar - } - - uploadArchives { - repositories.mavenDeployer { - pom.whenConfigured { p -> p.dependencies.clear() } + publishing.publications { + maven(MavenPublication) { + afterEvaluate { + pom.withXml { + def xmlNode = asNode() + xmlNode.remove(xmlNode.get('dependencies')) + } + } } } } + +// do not publish normal jar (which is non-existent) +publishArtifacts = [ shadowJar, packageSources, packageScalaDocs ] diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index ff36466697..4640ab7089 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -104,82 +104,129 @@ artifactId: snappydata-cluster_2.11 version: 1.3.1 ``` -Also add cloudera repository to the set of Maven repositories to be searched: - -```xml - - - cloudera-repo - cloudera repo - https://repository.cloudera.com/artifactory/cloudera-repos - - ... - -``` - -### Using Gradle Dependency - -If you are using Gradle, add this to your **build.gradle** for core SnappyData artifacts: - -```groovy -dependencies { - implementation 'io.snappydata:snappydata-core_2.11:1.3.1' - ... -} -``` - -For additions related to SnappyData cluster, use: - -```groovy -dependencies { - implementation 'io.snappydata:snappydata-cluster_2.11:1.3.1' - ... -} -``` - -Also add cloudera repository to the set of Maven repositories to be searched: - -```groovy -repositories { - mavenCentral() - maven { url 'https://repository.cloudera.com/artifactory/cloudera-repos' } - ... -} -``` - -### Using SBT Dependency - -If you are using SBT, add this line to your **build.sbt** for core SnappyData artifacts: +If you do not need the cluster additions (having job support) rather only the [smart connector](affinity_modes/connector_mode.md) then use the following coordinates: -```scala -libraryDependencies += "io.snappydata" % "snappydata-core_2.11" % "1.3.1" ``` - -For additions related to SnappyData cluster, use: - -```scala -libraryDependencies += "io.snappydata" % "snappydata-cluster_2.11" % "1.3.1" +groupId: io.snappydata +artifactId: snappydata-core_2.11 +version: 1.3.1 ``` -Also add cloudera repository to the set of Maven repositories to be searched: - -```scala -resolvers += "Cloudera Repo" at "https://repository.cloudera.com/artifactory/cloudera-repos" -``` +Also add cloudera repository `https://repository.cloudera.com/artifactory/cloudera-repos` to the set of Maven repositories to be searched. + +Example configuration for smart connector mode: + +=== "Maven" + + ```xml + + + + cloudera-repo + cloudera repo + https://repository.cloudera.com/artifactory/cloudera-repos + + ... + + + + + io.snappydata + snappydata-core_2.11 + 1.3.1 + + ... + + ``` + +=== "Gradle" + + ```groovy + // https://mvnrepository.com/artifact/io.snappydata/snappydata-core_2.11 + repositories { + mavenCentral() + maven { url 'https://repository.cloudera.com/artifactory/cloudera-repos' } + ... + } + + dependencies { + implementation 'io.snappydata:snappydata-core_2.11:1.3.1' + ... + } + ``` + +=== "SBT" + + ```scala + // https://mvnrepository.com/artifact/io.snappydata/snappydata-core_2.11 + resolvers += "Cloudera Repo" at "https://repository.cloudera.com/artifactory/cloudera-repos" + + libraryDependencies += "io.snappydata" % "snappydata-core_2.11" % "1.3.1" + ``` + +Example configuration for full cluster mode: + +=== "Maven" + + ```xml + + + + cloudera-repo + cloudera repo + https://repository.cloudera.com/artifactory/cloudera-repos + + ... + + + + + io.snappydata + snappydata-cluster_2.11 + 1.3.1 + + ... + + ``` + +=== "Gradle" + + ```groovy + // https://mvnrepository.com/artifact/io.snappydata/snappydata-cluster_2.11 + repositories { + mavenCentral() + maven { url 'https://repository.cloudera.com/artifactory/cloudera-repos' } + ... + } + + dependencies { + implementation 'io.snappydata:snappydata-cluster_2.11:1.3.1' + ... + } + ``` + +=== "SBT" + + ```scala + // https://mvnrepository.com/artifact/io.snappydata/snappydata-cluster_2.11 + resolvers += "Cloudera Repo" at "https://repository.cloudera.com/artifactory/cloudera-repos" + + libraryDependencies += "io.snappydata" % "snappydata-cluster_2.11" % "1.3.1" + ``` You can find more specific SnappyData artifacts [here](http://mvnrepository.com/artifact/io.snappydata) !!!Note - If your project fails when resolving the above dependency (that is, it fails to download `javax.ws.rs#javax.ws.rs-api;2.1`), it may be due an issue with its pom file.
As a workaround, you can add the below code to your **build.sbt**: + If your project fails when resolving the above dependency (that is, it fails to download `javax.ws.rs#javax.ws.rs-api;2.1`), it may be due an issue with its pom file.
As a workaround, you can add the below code to your **build.sbt**: -``` scala -val workaround = { - sys.props += "packaging.type" -> "jar" - () -} -``` + ```scala + val workaround = { + sys.props += "packaging.type" -> "jar" + () + } + ``` -For more details, refer [https://github.com/sbt/sbt/issues/3618](https://github.com/sbt/sbt/issues/3618). + For more details, refer [https://github.com/sbt/sbt/issues/3618](https://github.com/sbt/sbt/issues/3618). ## Building from Source diff --git a/dtests/build.gradle b/dtests/build.gradle index bc0ec5184e..c58f1abbd7 100644 --- a/dtests/build.gradle +++ b/dtests/build.gradle @@ -104,9 +104,7 @@ task buildDtests { dependsOn ':cleanScalaTest', ':snappy-store:storeProduct', ':product', packageTests } -artifacts { - archives packageTests -} +publishArtifacts.add(packageTests) archivesBaseName = 'snappydata-store-scala-tests' diff --git a/dunit/build.gradle b/dunit/build.gradle index 56bf9ab277..1708abac25 100644 --- a/dunit/build.gradle +++ b/dunit/build.gradle @@ -18,7 +18,7 @@ apply plugin: 'java' group = 'io.snappydata' -version = '1.0.3.7' +version = '1.0.3.8' compileJava.options.encoding = 'UTF-8' @@ -32,8 +32,4 @@ dependencies { } } -if (rootProject.hasProperty('enablePublish')) { - artifacts { - archives packageDocs - } -} +publishArtifacts.add(packageDocs) diff --git a/jdbc/build.gradle b/jdbc/build.gradle index eb547010ed..2dfbcc3892 100644 --- a/jdbc/build.gradle +++ b/jdbc/build.gradle @@ -107,19 +107,17 @@ shadowJar { } // clear dependencies from shadowJar POM -install { - repositories.mavenInstaller { - pom.whenConfigured { p -> p.dependencies.clear() } - } -} if (rootProject.hasProperty('enablePublish')) { - artifacts { - archives shadowJar - } - - uploadArchives { - repositories.mavenDeployer { - pom.whenConfigured { p -> p.dependencies.clear() } + publishing.publications { + maven(MavenPublication) { + afterEvaluate { + pom.withXml { + def xmlNode = asNode() + xmlNode.remove(xmlNode.get('dependencies')) + } + } } } } + +publishArtifacts.add(shadowJar) diff --git a/spark b/spark index 11a8f80a6f..cba053b332 160000 --- a/spark +++ b/spark @@ -1 +1 @@ -Subproject commit 11a8f80a6fd2effabb5f88660b44b6e0f6272dcd +Subproject commit cba053b332d29b4fb01ffc55b136b613024c87cf diff --git a/store b/store index 6077ca4924..316609bf10 160000 --- a/store +++ b/store @@ -1 +1 @@ -Subproject commit 6077ca4924f41c0b78b815cfd6c9054b61854535 +Subproject commit 316609bf109bfa4c9719b3c80f5a8ac58f1b411c