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
131 changes: 66 additions & 65 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ spotbugsMain {
excludeFilter = file("spotBugsExcludeFilter.xml")
reports {
html {
enabled = true
destination = file("$buildDir/reports/spotbugs/main/spotbugs.html")
required
outputLocation = new File("$buildDir/reports/spotbugs/main/spotbugs.html")
stylesheet = 'fancy-hist.xsl'
}
}
Expand All @@ -49,16 +49,17 @@ spotbugsTest {
excludeFilter = file("spotBugsExcludeFilter.xml")
reports {
html {
enabled = true
destination = file("$buildDir/reports/spotbugs/test/spotbugs.html")
required
outputLocation = new File('$buildDir/reports/spotbugs/test/spotbugs.html')
stylesheet = 'fancy-hist.xsl'

}
}
}

jacocoTestReport {
reports {
xml.enabled true
xml.required
}
}

Expand All @@ -74,7 +75,7 @@ sourceSets {
repositories {
// You can declare any Maven/Ivy/file repository here.
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } // for jacoco, until 0.8.7 gets released
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }// for jacoco, until 0.8.7 gets released
}

apply from: "gradle/dependencies.gradle"
Expand All @@ -90,11 +91,11 @@ def pomConfig = {
}

sonarqube {
properties {
property "sonar.projectKey", "microsoftgraph_msgraph-sdk-java-core"
property "sonar.organization", "microsoftgraph2"
property "sonar.host.url", "https://sonarcloud.io"
}
properties {
property "sonar.projectKey", "microsoftgraph_msgraph-sdk-java-core"
property "sonar.organization", "microsoftgraph2"
property "sonar.host.url", "https://sonarcloud.io"
}
}

//Publishing tasks-
Expand Down Expand Up @@ -128,7 +129,7 @@ publishing {
version "${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}${mavenArtifactSuffix}"
from components.java
artifact sourceJar
artifact javadocJar
artifact javadocJar
pom.withXml {
def root = asNode()
root.appendNode('name', 'Microsoft Graph Core SDK for Java')
Expand All @@ -140,59 +141,59 @@ publishing {

}
Snapshot(MavenPublication) {
customizePom(pom)
groupId project.property('mavenGroupId')
artifactId project.property('mavenArtifactId')
version "${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}${mavenCentralSnapshotArtifactSuffix}"
from components.java
pom.withXml {
def pomFile = file("${project.buildDir}/generated-pom.xml")
writeTo(pomFile)
}
artifact sourceJar
artifact javadocJar
}
mavenCentralRelease(MavenPublication) {
customizePom(pom)
groupId project.property('mavenGroupId')
artifactId project.property('mavenArtifactId')
version "${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}"
from components.java
pom.withXml {
def pomFile = file("${project.buildDir}/generated-pom.xml")
writeTo(pomFile)
}
artifact sourceJar
artifact javadocJar
}
customizePom(pom)
groupId project.property('mavenGroupId')
artifactId project.property('mavenArtifactId')
version "${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}${mavenCentralSnapshotArtifactSuffix}"
from components.java
pom.withXml {
def pomFile = file("${project.buildDir}/generated-pom.xml")
writeTo(pomFile)
}
artifact sourceJar
artifact javadocJar
}

mavenCentralRelease(MavenPublication) {
customizePom(pom)
groupId project.property('mavenGroupId')
artifactId project.property('mavenArtifactId')
version "${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}"
from components.java
pom.withXml {
def pomFile = file("${project.buildDir}/generated-pom.xml")
writeTo(pomFile)
}
artifact sourceJar
artifact javadocJar
}
Comment on lines +144 to +169
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor issue: @ramsessanchez @baywet We can consider configuring a deterministic code formatter to avoid diff due to indenting and prevent merging code that's not formatted al together.

I've worked with spotless which can be configured to check PR's and can be used a maven / gradle plugin. For the formatting rules we can use a derivative of google-formatter

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go for it! I usually rely on editor config, but as long as it works on vs code I'm happy. Don't hesitate to pr microsoft/kiota-java (no need to PR the service libs)

}
repositories {
repositories {
maven {
url = 'https://oss.sonatype.org/content/repositories/snapshots'
name = 'sonatypeSnapshot'

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')
}
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 = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
name = 'sonatype'

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')
}
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')
}
}
}
}
Expand All @@ -203,7 +204,7 @@ signing {
}
tasks.withType(Sign)*.enabled = mavenCentralPublishingEnabled.toBoolean()

def fixAscNames = { name ->
def fixAscNames = { name ->
if(name.contains('pom')) {
"${project.property('mavenArtifactId')}-${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}.pom.asc"
} else {
Expand All @@ -212,8 +213,8 @@ def fixAscNames = { name ->
}

compileJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = '17'
targetCompatibility = '17'
}

def getVersionCode() {
Expand All @@ -225,9 +226,9 @@ def getVersionName() {
}

artifacts {
archives jar
archives sourceJar
archives javadocJar
archives jar
archives sourceJar
archives javadocJar
}

def customizePom(pom) {
Expand Down Expand Up @@ -255,14 +256,14 @@ def customizePom(pom) {
licenses {
license {
name "MIT License"
url "http://opensource.org/licenses/MIT"
distribution "repo"
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'
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 {
Expand All @@ -274,13 +275,13 @@ def customizePom(pom) {
}

gradle.taskGraph.whenReady { taskGraph ->
if (project.rootProject.file('local.properties').exists()) {
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') }
allprojects { ext."signing.password" = properties.getProperty('signing.password') }
}
}

Expand Down
7 changes: 7 additions & 0 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@ dependencies {
compileOnly 'com.github.spotbugs:spotbugs-annotations:4.7.0'
testCompileOnly 'net.jcip:jcip-annotations:1.0'
testCompileOnly 'com.github.spotbugs:spotbugs-annotations:4.7.0'

implementation 'com.microsoft.kiota:microsoft-kiota-abstractions:0.0.1-SNAPSHOT'
implementation 'com.microsoft.kiota:microsoft-kiota-authentication-azure:0.0.1-SNAPSHOT'
implementation 'com.microsoft.kiota:microsoft-kiota-http-okHttp:0.0.1-SNAPSHOT'
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-json:0.0.1-SNAPSHOT'
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-text:0.0.1-SNAPSHOT'

}
65 changes: 65 additions & 0 deletions src/main/java/com/microsoft/graph/Requests/BaseClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.microsoft.graph.Requests;

import com.microsoft.graph.content.BatchRequestBuilder;
import com.microsoft.kiota.RequestAdapter;
import com.microsoft.kiota.authentication.AuthenticationProvider;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import okhttp3.OkHttpClient;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
* Default client implementation.
*/
public class BaseClient implements IBaseClient{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe we can have a base client (class) in core anymore.
That's because the GeneratedGraphServiceClient will be a class that doesn't inherit from this one and Java doesn't support multiple inheritance.
So this will either have to move to the service library and inherit from the generated client or be removed all together.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Vincent, it seems that in C# there is this baseClient class as a means to create a lightweight client that doesn't rely on the service library. I believe we can keep this class here as GraphServiceClient will extend from BaseGraphServiceClient and implement IBaseClient. This is the same pattern that we have in C#. This means I will have to create the GraphServiceClient following the same pattern that is already in C#, but I believe we can keep both.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright, but just to be clear, this one won't be in the inheritance structure of a client for somebody using the graph service client from the service lib, correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, the the GraphServiceClient will extend the BaseGraphServiceClient and implement IBaseClient, GraphServiceClient will not use any BaseClient implementations.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so should this class be removed from the PR?


private RequestAdapter requestAdapter;
/** RequestBuilder for completing Batch Requests */
public BatchRequestBuilder batchRequestBuilder;

/**
* Constructor requiring only a RequestAdapter.
*
* @param requestAdapter the specified RequestAdapter used to complete requests.
*/
public BaseClient(@Nonnull RequestAdapter requestAdapter) {
setRequestAdapter(requestAdapter);
}

/**
* Constructor requiring only an AuthenticationProvider.
*
* @param authenticationProvider the specified AuthenticationProvider for use in requests.
*/
public BaseClient(@Nonnull AuthenticationProvider authenticationProvider) {
this(new BaseGraphRequestAdapter(authenticationProvider));
}

/**
* Constructor requiring an AuthenticationProvider and Base URL.
*
* @param authenticationProvider the specified AuthenticationProvider for use in requests.
* @param baseUrl the specified base URL for use in requests.
*/
public BaseClient(@Nonnull AuthenticationProvider authenticationProvider, @Nonnull String baseUrl) {
this(new BaseGraphRequestAdapter(authenticationProvider, baseUrl));
}

@Override
public void setRequestAdapter(RequestAdapter requestAdapter) {
this.requestAdapter = requestAdapter;
}

@Override
public RequestAdapter getRequestAdapter() {
return this.requestAdapter;
}

@Override
public BatchRequestBuilder getBatchRequestBuilder() {
//TODO: Refactor BatchRequestBuilder so that it accepts a request adapter as the param
//return this.batchRequestBuilder != null ? this.batchRequestBuilder : new BatchRequestBuilder(this.requestAdapter)
return this.batchRequestBuilder;
}
}
Loading