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

Bundle for java #1450

Merged
merged 6 commits into from
Jul 31, 2024
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
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
Copy-Item secring.gpg components/serialization/json/ -Verbose
Copy-Item secring.gpg components/serialization/multipart/ -Verbose
Copy-Item secring.gpg components/http/okHttp/ -Verbose
Copy-Item secring.gpg components/bundle/ -Verbose
shell: pwsh
working-directory: ./
- name: Build with Gradle
Expand Down Expand Up @@ -96,6 +97,7 @@ jobs:
Copy-Item secring.gpg components/serialization/json/ -Verbose
Copy-Item secring.gpg components/serialization/multipart/ -Verbose
Copy-Item secring.gpg components/http/okHttp/ -Verbose
Copy-Item secring.gpg components/bundle/ -Verbose
shell: pwsh
working-directory: ./
- name: Build with Gradle
Expand All @@ -122,6 +124,9 @@ jobs:
- name: Publish Release okHttp
run: ./gradlew --no-daemon :components:http:okHttp:$PUBLISH_TASK -PmavenCentralSnapshotArtifactSuffix=""
working-directory: ./
- name: Publish Release bundle
run: ./gradlew --no-daemon :components:bundle:$PUBLISH_TASK -PmavenCentralSnapshotArtifactSuffix=""
working-directory: ./
- name: Release
uses: anton-yurchenko/git-release@v6.0
env:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.2.0] - 2024-07-25

### Changed

- Adds bundle package for Kiota [#1420](https://github.com/microsoft/kiota-java/issues/1420).

## [1.1.14] - 2024-06-10

### Changed
Expand Down
10 changes: 10 additions & 0 deletions components/bundle/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build


.settings
.project
.classpath
2 changes: 2 additions & 0 deletions components/bundle/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.gradle
build
23 changes: 23 additions & 0 deletions components/bundle/android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto"
tools:ignore="UnusedAttribute">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />

<application
android:hardwareAccelerated="true"
android:fullBackupContent="true"
android:allowBackup="true"
android:supportsRtl="true"
tools:ignore="GoogleAppIndexingWarning"></application>
</manifest>
73 changes: 73 additions & 0 deletions components/bundle/android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
buildscript {
repositories {
google()
gradlePluginPortal()
maven {
url "https://plugins.gradle.org/m2/"
}
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}

dependencies {
classpath "com.gradle:gradle-enterprise-gradle-plugin:3.17.5"
classpath "com.android.tools.build:gradle:8.5.1"
classpath "com.github.ben-manes:gradle-versions-plugin:0.51.0"
}
}

repositories {
google()
gradlePluginPortal()
}

apply plugin: "com.android.library"
apply plugin: "com.github.ben-manes.versions"

android {
namespace "com.microsoft.kiota.bundle"
compileSdkVersion 35

defaultConfig {
versionCode 1
versionName "1.0"
minSdkVersion 26
targetSdkVersion 35
}

buildTypes {
release {
minifyEnabled false
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

lintOptions {
textOutput "stdout"
checkAllWarnings true
warningsAsErrors true
disable "UnusedResources" // Unused will be removed on release
disable "IconExpectedSize" // Using the material icons provided from Google
disable "GoogleAppIndexingApiWarning" // We might want to index our app later
disable "InvalidPackage" // Butterknife, Okio and Realm
disable "ResourceType" // Annotation binding
disable "GradleDependency"
disable "NewerVersionAvailable"
disable "DuplicatePlatformClasses" // xpp3 added by azure-identity
}
sourceSets {
main {
java.srcDirs = ['../src/main/java']
res.srcDirs = ['../src/main/java']
manifest.srcFile 'AndroidManifest.xml'
}
androidTest {
setRoot '../src/test'
}
}
}

apply from: "../gradle/dependencies.gradle"
1 change: 1 addition & 0 deletions components/bundle/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mavenArtifactId = microsoft-kiota-bundle
227 changes: 227 additions & 0 deletions components/bundle/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
plugins {
// Apply the java-library plugin to add support for Java Library
id 'java-library'
id 'eclipse'
id 'maven-publish'
id 'signing'
id 'jacoco'
id 'com.github.spotbugs'
id 'com.diffplug.spotless'
}

java {
modularity.inferModulePath = true
withSourcesJar()
withJavadocJar()
}

test {
useJUnitPlatform()
finalizedBy jacocoTestReport // report is always generated after tests run
}

jacocoTestReport {
dependsOn test // tests are required to run before generating the report
reports.xml.required = true
}

jacoco {
toolVersion = "0.8.11"
}

spotbugsMain {
excludeFilter = file("spotBugsExcludeFilter.xml")
reports {
html {
required
outputLocation = file("$buildDir/reports/spotbugs/main/spotbugs.html")
stylesheet = 'fancy-hist.xsl'
}
}
}

spotbugsTest {
excludeFilter = file("spotBugsExcludeFilter.xml")
reports {
html {
required
outputLocation = file("$buildDir/reports/spotbugs/test/spotbugs.html")
stylesheet = 'fancy-hist.xsl'
}
}
}

sourceSets {
main {
java {
exclude 'pom.xml'
}
}
}

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

apply from: "gradle/dependencies.gradle"

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

//Publishing tasks-
//Maven Central Snapshot: publishMavenPublicationToMavenRepository
//Maven Central Release: publishmavenPublicationToMaven2Repository

tasks.jar {
manifest {
attributes('Automatic-Module-Name': project.property('mavenGroupId'))
}
}

publishing {

publications {
maven(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)
}
}
}
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')
}
}
}

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')
}
}
}
}
}

signing {
sign publishing.publications.maven
}
tasks.withType(Sign)*.enabled = mavenCentralPublishingEnabled.toBoolean()

def fixAscNames = { name ->
if(name.contains('pom')) {
"${project.property('mavenArtifactId')}-${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}.pom.asc"
} else {
name.replace('microsoft-kiota-bundle', "${project.property('mavenArtifactId')}-${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}")
}
}

compileJava {
options.compilerArgs << "-parameters"
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}

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

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

artifacts {
archives jar
}

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

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

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

description 'Microsoft Kiota-Bundle'
name 'Microsoft Kiota-Java Bundle'
url 'https://github.com/microsoft/kiota-java'
organization {
name 'Microsoft'
url 'https://github.com/microsoft/kiota-java'
}
issueManagement {
system 'GitHub'
url 'https://github.com/microsoft/kiota-java/issues'
}
licenses {
license {
name "MIT License"
url "http://opensource.org/licenses/MIT"
distribution "repo"
}
}
scm {
url 'https://github.com/microsoft/kiota-java'
connection 'scm:git:git://github.com/microsoft/kiota-java.git'
developerConnection 'scm:git:ssh://git@github.com:microsoft/kiota-java.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.generatePomFileForMavenPublication {
destination = file("${project.buildDir}/generated-pom.xml")
}
}

apply from: file('../../spotless.groovy')
1 change: 1 addition & 0 deletions components/bundle/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mavenArtifactId = microsoft-kiota-bundle
Loading
Loading