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

[WIP] Added sonatype publishing task #320

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip
8 changes: 8 additions & 0 deletions syft/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ apply plugin: 'org.jetbrains.dokka'
apply plugin: 'maven-publish'
apply from: 'publish.gradle'

ext {
PUBLISH_GROUP_ID = 'org.openmined'
PUBLISH_VERSION = '0.5.0-test-SNAPSHOT'
PUBLISH_ARTIFACT_ID = 'syft'
}

apply from: "./publish-mavencentral.gradle"

jacoco {
toolVersion = Versions.jacocoVersion
}
Expand Down
129 changes: 129 additions & 0 deletions syft/publish-mavencentral.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
if (project.plugins.findPlugin("com.android.library")) {
// For Android libraries
from android.sourceSets.main.java.srcDirs
from android.sourceSets.main.kotlin.srcDirs
} else {
// For pure Kotlin libraries, in case you have them
from sourceSets.main.java.srcDirs
from sourceSets.main.kotlin.srcDirs
}
}

artifacts {
archives androidSourcesJar
}

group = PUBLISH_GROUP_ID
version = PUBLISH_VERSION

ext["signing.keyId"] = ''
ext["signing.password"] = ''
ext["signing.secretKeyRingFile"] = ''
ext["ossrhUsername"] = ''
ext["ossrhPassword"] = ''
ext["sonatypeStagingProfileId"] = ''

File secretPropsFile = project.rootProject.file('local.properties')
if (secretPropsFile.exists()) {
Properties p = new Properties()
new FileInputStream(secretPropsFile).withCloseable { is ->
p.load(is)
}
p.each { name, value ->
ext[name] = value
}
} else {
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
}

publishing {
publications {
release(MavenPublication) {
// The coordinates of the library, being set from variables that
// we'll set up later
groupId PUBLISH_GROUP_ID
artifactId PUBLISH_ARTIFACT_ID
version PUBLISH_VERSION

// Two artifacts, the `aar` (or `jar`) and the sources
if (project.plugins.findPlugin("com.android.library")) {
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
} else {
artifact("$buildDir/libs/${project.getName()}-${version}.jar")
}
artifact androidSourcesJar

// Mostly self-explanatory metadata
pom {
name = PUBLISH_ARTIFACT_ID
description = 'The official Syft worker for secure on-device machine learning on Android'
url = 'https://github.com/OpenMined/KotlinSyft'
licenses {
license {
name = 'Apache 2.0'
url = 'https://github.com/OpenMined/KotlinSyft/blob/dev/LICENSE'
}
}
developers {
developer {
id = 'vkkhare'
name = 'Varun Khare'
email = '[email protected]'
}

developer {
id = 'mccorby'
name = 'Jose Corbacho'
email = '[email protected]'
}
// Add all other devs here...
}
// Version control info - if you're using GitHub, follow the format as seen here
scm {
connection = 'scm:git:github.com/OpenMined/KotlinSyft.git'
developerConnection = 'scm:git:ssh://github.com/OpenMined/KotlinSyft.git'
url = 'https://github.com/OpenMined/KotlinSyft.git/tree/dev'
}
// A slightly hacky fix so that your POM will include any transitive dependencies
// that your library builds upon
withXml {
def dependenciesNode = asNode().appendNode('dependencies')

project.configurations.implementation.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
// The repository to publish to, Sonatype/MavenCentral
repositories {
maven {
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
name = "sonatype"
credentials {
username ossrhUsername
password ossrhPassword
}
}
}
}

signing {
sign publishing.publications
}