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

Update publishing tasks #2107

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 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
1 change: 1 addition & 0 deletions changelog
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ MSAL Wiki : https://github.com/AzureAD/microsoft-authentication-library-for-andr
vNext
----------
- [MINOR] Support for multiple access tokens in NativeAuth (#2082)
- [MINOR] Update publishing tasks (#2107)

Version 5.3.1
---------
Expand Down
2 changes: 1 addition & 1 deletion common
Submodule common updated 2 files
+1 −0 changelog.txt
+9 −47 common/build.gradle
147 changes: 29 additions & 118 deletions msal/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,6 @@ android {
}
}

libraryVariants.all { variant ->
variant.outputs.all {
def fileName = "${archivesBaseName}-${version}.aar"
outputFileName = fileName
}
}

testOptions {
unitTests.all {
if (!project.hasProperty('labtest')) {
Expand All @@ -155,35 +148,13 @@ android {
}
}
}
}

// Task to generate javadoc
task javadoc(type: Javadoc) {
failOnError false
source = android.sourceSets.main.java.srcDirs
configurations.api.setCanBeResolved(true)
classpath += configurations.api
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))

options.memberLevel = JavadocMemberLevel.PUBLIC
options.addStringOption('Xdoclint:none', '-quiet')

exclude '**/BuildConfig.Java'
exclude '**/R.java'
destinationDir = reporting.file("$project.buildDir/outputs/jar/javadoc/")
}

// Task to generate javadoc.jar
task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
classifier 'javadoc'
destinationDirectory = reporting.file("$project.buildDir/outputs/jar/")
}

task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier 'sources'
destinationDirectory = reporting.file("$project.buildDir/outputs/jar/")
publishing {
singleVariant('distRelease') {
withSourcesJar()
withJavadocJar()
}
}
}

// In dev, we want to keep the dependencies (common4j, common) to 1.0.+ to be able to be consumed by daily dev pipeline.
Expand Down Expand Up @@ -305,90 +276,42 @@ task pmd(type: Pmd) {
}
}

afterEvaluate {
// Gradle 6.1.1 and Android Gradle Plugin 4.0.1 doesn't rename the file (see 'outputFileName' above)
// Adding this work around to have the file properly renamed.
tasks.named("assembleDistRelease").configure {
def buildFile = file("$buildDir/outputs/aar/${archivesBaseName}-dist-release.aar")
print "Build file $buildFile"
doLast {
println "Renaming build file $buildFile to '$buildDir${File.separator}outputs${File.separator}aar${File.separator}${archivesBaseName}-${version}.aar'"
if (!buildFile.renameTo("$buildDir${File.separator}outputs${File.separator}aar${File.separator}${archivesBaseName}-${version}.aar")) {
println "Rename failed!"
}
}
}
}

publishing {
publications {
msal(MavenPublication) {
afterEvaluate {
from components.distRelease
}
groupId 'com.microsoft.identity.client'
artifactId 'msal'
//Edit the 'version' here for VSTS RC build
version = project.version

pom.withXml {
// Custom values

// Name
asNode().appendNode('name', 'msal')

// Description
asNode().appendNode(
'description',
'Microsoft Identity library for Android gives you the ability to add authentication to your application with just a few lines of additional code. Using our MSAL SDKs you can quickly and easily extend your existing application to all the employees that use MSA, B2C, Azure AD and Active Directory on-premises using Active Directory Federation Services, including Office365 customers.'
)

// URL
asNode().appendNode('url', 'https://github.com/AzureAD/microsoft-authentication-library-for-android')

// Inception Year
asNode().appendNode('inceptionYear', '2016')

// Licenses
asNode().appendNode('licenses').appendNode('license').appendNode('name', 'MIT License')

// Developers
def developerNode = asNode().appendNode('developers').appendNode('developer')
developerNode.appendNode('id', 'microsoft')
developerNode.appendNode('name', 'Microsoft')

// SCM
asNode().appendNode('scm').appendNode('url', 'https://github.com/AzureAD/microsoft-authentication-library-for-android/tree/master')

// Properties
def propertiesNode = asNode().appendNode('properties')
propertiesNode.appendNode('branch', 'master')
propertiesNode.appendNode('version', project.version)

def dependenciesNode = asNode().appendNode('dependencies')


def deps = configurations.implementation.allDependencies.asList()
if (project.version.toString().endsWith("SNAPSHOT")) {
deps.addAll(configurations.snapshotApi.allDependencies.asList())
} else {
deps.addAll(configurations.distApi.allDependencies.asList())
pom {
name = 'msal'
description = 'Microsoft Identity library for Android gives you the ability to add authentication to your application with just a few lines of additional code. Using our MSAL SDKs you can quickly and easily extend your existing application to all the employees that use MSA, B2C, Azure AD and Active Directory on-premises using Active Directory Federation Services, including Office365 customers.'
url = 'https://github.com/AzureAD/microsoft-authentication-library-for-android'
developers {
developer {
id = 'microsoft'
name = 'Microsoft'
}
}

//Iterate over the implementation dependencies (we don't want the test ones), adding a <dependency> node for each
deps.each {
if (it.group != null && it.name != null) {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
licenses {
license {
name = 'MIT License'
}
}

inceptionYear = '2016'
scm {
url = 'https://github.com/AzureAD/microsoft-authentication-library-for-android/tree/master'
}
properties = [
branch : 'master',
version: project.version
]
}

artifact(sourcesJar)
artifact(javadocJar)
artifact("$buildDir/outputs/aar/msal-${project.version}.aar")
}

}

// Repositories to which Gradle can publish artifacts
Expand All @@ -408,16 +331,4 @@ tasks.whenTaskAdded { task ->
if (task.name.contains('assemble')) {
task.dependsOn 'pmd'
}

if (task.name.contains('assemble')
&& !task.name.contains('Snapshot')
&& !task.name.contains('Test')
&& !task.name.contains('Local')) {
task.dependsOn 'javadocJar', 'sourcesJar'
}
}

// This is used to generate the pom file for publishing to external maven in maven-release-jobs.yml
tasks.withType(GenerateMavenPom).all {
destination = layout.buildDirectory.file("poms/${project.name}-${project.version}.pom").get().asFile
}
Loading