Skip to content
Merged
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
322 changes: 317 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,347 @@
*
* This generated file contains a sample Java Library project to get you started.
* For more details take a look at the Java Libraries chapter in the Gradle
* user guide available at https://docs.gradle.org/4.3/userguide/java_library_plugin.html
* user guide available at https://docs.gradle.org/4.5/userguide/java_library_plugin.html
*/

// Apply the java-library plugin to add support for Java Library
apply plugin: 'java-library'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'jacoco'

// In this section you declare where to find the dependencies of your project
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
mavenCentral()
}

def platformDependency = "org.apache.httpcomponents:httpclient:4.5.6"
if ( project.hasProperty("platform") && project.platform == "android" ) {
platformDependency = "org.apache.httpcomponents:httpclient-android:4.3.5"
}

dependencies {
// This dependency is exported to consumers, that is to say found on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'

// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:23.0'
implementation 'com.google.guava:guava:20.0'

// Use JUnit test framework
testImplementation 'junit:junit:4.12'

// Use Apache HttpClient
api 'org.apache.httpcomponents:httpclient:4.5.6'
api platformDependency

// https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1'

}

def pomConfig = {
licenses {
license([:]) {
name "MIT License"
url "http://opensource.org/licenses/MIT"
distribution "repo"
}
}
}

//Publishing tasks-
//Maven Central Snapshot: publishSnapshotPublicationToMavenRepository
//Maven Central Release: publishMavenCentralReleasePublicationToMaven2Repository
//Bintray Snapshot: publishSnapshotPublicationToMaven3Repository
//Bintray Release: uploadArchives

publishing {

publications {

maven(MavenPublication) {

groupId 'com.microsoft.graph'

artifactId 'microsoft-graph-core'

version "${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}${mavenArtifactSuffix}"

from components.java

artifact sourceJar
pom.withXml {
def root = asNode()
root.appendNode('name', 'Microsoft Graph Core SDK for Java')
root.appendNode('url', 'https://github.com/microsoftgraph/msgraph-sdk-java-core')
root.children().last() + pomConfig
def pomFile = file("${project.buildDir}/libs/microsoft-graph-core.pom")
writeTo(pomFile)
}

}
Snapshot(MavenPublication) {
customizePom(pom)
groupId 'com.microsoft.graph'
artifactId 'microsoft-graph-core'
version "${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}${mavenCentralSnapshotArtifactSuffix}"
from components.java
pom.withXml {
def pomFile = file("${project.buildDir}/generated-pom.xml")
writeTo(pomFile)
}
artifact(sourceJar) {
classifier = 'sources'
}
artifact(javadocJar) {
classifier = 'javadoc'
}
}

mavenCentralRelease(MavenPublication) {
customizePom(pom)
groupId 'com.microsoft.graph'
artifactId 'microsoft-graph-core'
version "${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}"
from components.java
pom.withXml {
def pomFile = file("${project.buildDir}/generated-pom.xml")
writeTo(pomFile)
def pomAscFile = signing.sign(pomFile).signatureFiles[0]
artifact(pomAscFile) {
classifier = null
extension = 'pom.asc'
}
}
artifact(sourceJar) {
classifier = 'sources'
}
artifact(javadocJar) {
classifier = 'javadoc'
}
project.tasks.signArchives.signatureFiles.each {
artifact(it) {
def matcher = it.file =~ /-(sources|javadoc)\.jar\.asc$/
if(matcher.find()){
classifier = matcher.group(1)
}
else{
classifier = null
}
extension = 'jar.asc'
}
}
}
}
repositories {
maven {
url = project.property('mavenCentralSnapshotUrl')

credentials {
if (project.rootProject.file('local.properties').exists()) {

Properties properties = new Properties()

properties.load(project.rootProject.file('local.properties').newDataInputStream())

username = properties.getProperty('sonatypeUsername')

password = properties.getProperty('sonatypePassword')

}
}
}

maven {
url = project.property('mavenCentralReleaseUrl')

credentials {
if (project.rootProject.file('local.properties').exists()) {

Properties properties = new Properties()

properties.load(project.rootProject.file('local.properties').newDataInputStream())

username = properties.getProperty('sonatypeUsername')

password = properties.getProperty('sonatypePassword')

}
}
}

maven {
url = project.property('mavenBintraySnapshotUrl')

credentials {
if (project.rootProject.file('local.properties').exists()) {

Properties properties = new Properties()

properties.load(project.rootProject.file('local.properties').newDataInputStream())

username = (properties.containsKey('bintray.user')) ? properties.getProperty('bintray.user').toLowerCase() : "BINTRAY_USERNAME"

password = properties.getProperty('bintray.apikey')

}
}
}
}

}

task sourceJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allJava
}

compileJava {
sourceCompatibility = 1.7
targetCompatibility = 1.7
}

def getVersionCode() {
return mavenMajorVersion.toInteger() * 10000 + mavenMinorVersion.toInteger() * 100 + mavenPatchVersion.toInteger()
}

def getVersionName() {
return "${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}${mavenArtifactSuffix}"
}

uploadArchives {

def bintrayUsername = ""

def bintrayApikey = ""

if (project.rootProject.file('local.properties').exists()) {

Properties properties = new Properties()

properties.load(project.rootProject.file('local.properties').newDataInputStream())

bintrayUsername = properties.getProperty('bintray.user')

bintrayApikey = properties.getProperty('bintray.apikey')

}

configuration = configurations.archives

repositories.mavenDeployer {

pom {

setGroupId project.mavenGroupId

setArtifactId project.mavenArtifactId

setVersion getVersionName()

}

repository (url: project.mavenRepoUrl) {

url = url + "/" + getVersionName()

authentication(

// put these values in local file ~/.gradle/gradle.properties

userName: project.hasProperty("bintrayUsername") ? project.bintrayUsername : bintrayUsername,

password: project.hasProperty("bintrayApikey") ? project.bintrayApikey : bintrayApikey

)

}

}

}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

artifacts {
archives jar
archives sourceJar
archives javadocJar
}

signing {
sign configurations.archives
}
tasks.withType(Sign)*.enabled = mavenCentralPublishingEnabled.toBoolean()

def customizePom(pom) {
pom.withXml {
def root = asNode()

root.dependencies.removeAll { dep ->
dep.scope == "test"
}

root.children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST

description 'Microsoft Graph Core SDK'
name 'Microsoft Graph Java Core SDK'
url 'https://github.com/microsoftgraph/msgraph-sdk-java-core'
organization {
name 'Microsoft'
url 'https://github.com/microsoftgraph/msgraph-sdk-java-core'
}
issueManagement {
system 'GitHub'
url 'https://github.com/microsoftgraph/msgraph-sdk-java-core/issues'
}
licenses {
license {
name "MIT License"
url "http://opensource.org/licenses/MIT"
distribution "repo"
}
}
scm {
url 'https://github.com/microsoftgraph/msgraph-sdk-java-core'
connection 'scm:git:git://github.com/microsoftgraph/msgraph-sdk-java-core.git'
developerConnection 'scm:git:ssh://git@github.com:microsoftgraph/msgraph-sdk-java-core.git'
}
developers {
developer {
name 'Microsoft'
}
}
}
}
}

gradle.taskGraph.whenReady { taskGraph ->
if (project.rootProject.file('local.properties').exists()) {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
tasks.withType(Sign)*.enabled = (properties.containsKey('enableSigning')) ? properties.getProperty('enableSigning').toBoolean() : false
allprojects { ext."signing.keyId" = properties.getProperty('signing.keyId') }
allprojects { ext."signing.secretKeyRingFile" = properties.getProperty('signing.secretKeyRingFile') }
allprojects { ext."signing.password" = properties.getProperty('signing.password') }
}
}

model {
tasks.generatePomFileForMavenCentralReleasePublication {
destination = file("$buildDir/generated-pom.xml")
}
tasks.publishMavenCentralReleasePublicationToMavenLocal {
dependsOn project.tasks.signArchives
}
tasks.publishMavenCentralReleasePublicationToMaven2Repository {
dependsOn project.tasks.signArchives
}
}
46 changes: 46 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Project-wide Gradle settings.

# IDE users:
# Settings specified in this file will override any Gradle settings
# configured through the IDE.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

# The size of the library demands a large amount of RAM to build. Increase as necessary if you get GC errors
## linux requires 10G, OSX requires 11G
org.gradle.jvmargs=-XX:MaxPermSize=512m -Xmx2g

mavenRepoUrl = https://api.bintray.com/content/microsoftgraph/Maven/microsoft-graph
mavenBintraySnapshotUrl = http://oss.jfrog.org/artifactory/oss-snapshot-local
mavenGroupId = com.microsoft.graph
mavenArtifactId = microsoft-graph-core
mavenMajorVersion = 0
mavenMinorVersion = 1
mavenPatchVersion = 0
mavenArtifactSuffix =
nightliesUrl = http://dl.bintray.com/MicrosoftGraph/Maven

#These values are used to run functional tests
#If you wish to run the functional tests, edit the gradle.properties
#file in your user directory instead of adding them here.
#ex: C:\Users\username\.gradle\gradle.properties
ClientId="CLIENT_ID"
Username="USERNAME"
Password="PASSWORD"

#enable mavenCentralPublishingEnabled to publish to maven central
mavenCentralSnapshotUrl=https://oss.sonatype.org/content/repositories/snapshots
mavenCentralReleaseUrl=https://oss.sonatype.org/service/local/staging/deploy/maven2
mavenCentralSnapshotArtifactSuffix = -SNAPSHOT
mavenCentralPublishingEnabled=false