Skip to content

Commit

Permalink
Switch from gradle maven plugin to maven-publish
Browse files Browse the repository at this point in the history
Gradle maven plugin is deprecated for quite a while, so switching to the new maven-publish.
  • Loading branch information
sumwale committed Jun 10, 2022
1 parent 3867703 commit be8d170
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 142 deletions.
2 changes: 1 addition & 1 deletion aqp
Submodule aqp updated 1 files
+1 −3 build.gradle
85 changes: 46 additions & 39 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
}
}
}

Expand Down Expand Up @@ -983,17 +989,18 @@ gradle.taskGraph.whenReady { graph ->

Set<String> 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) }
}

Expand Down
24 changes: 11 additions & 13 deletions connector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
179 changes: 113 additions & 66 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<repositories>
<repository>
<id>cloudera-repo</id>
<name>cloudera repo</name>
<url>https://repository.cloudera.com/artifactory/cloudera-repos</url>
</repository>
...
</repositories>
```

### 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
<!-- https://mvnrepository.com/artifact/io.snappydata/snappydata-core_2.11 -->
<repositories>
<repository>
<id>cloudera-repo</id>
<name>cloudera repo</name>
<url>https://repository.cloudera.com/artifactory/cloudera-repos</url>
</repository>
...
</repositories>

<dependencies>
<dependency>
<groupId>io.snappydata</groupId>
<artifactId>snappydata-core_2.11</artifactId>
<version>1.3.1</version>
</dependency>
...
</dependencies>
```

=== "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
<!-- https://mvnrepository.com/artifact/io.snappydata/snappydata-cluster_2.11 -->
<repositories>
<repository>
<id>cloudera-repo</id>
<name>cloudera repo</name>
<url>https://repository.cloudera.com/artifactory/cloudera-repos</url>
</repository>
...
</repositories>

<dependencies>
<dependency>
<groupId>io.snappydata</groupId>
<artifactId>snappydata-cluster_2.11</artifactId>
<version>1.3.1</version>
</dependency>
...
</dependencies>
```

=== "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. </br> 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. </br> 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
Expand Down
4 changes: 1 addition & 3 deletions dtests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ task buildDtests {
dependsOn ':cleanScalaTest', ':snappy-store:storeProduct', ':product', packageTests
}

artifacts {
archives packageTests
}
publishArtifacts.add(packageTests)

archivesBaseName = 'snappydata-store-scala-tests'

Expand Down
Loading

0 comments on commit be8d170

Please sign in to comment.