-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replaces Bintray gradle plugin with maven-publishing
- Loading branch information
Jamie Sanson
committed
Apr 30, 2018
1 parent
04a19a0
commit 5c383b9
Showing
7 changed files
with
30 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
ext.version = "1.0.5" | ||
ext.version = "1.0.6" | ||
ext.group = "nz.co.trademe.mapme" | ||
ext.repo = "MapMe" | ||
ext.org = "trademe" | ||
ext.scm = 'https://github.com/TradeMe/MapMe.git' | ||
ext.description = 'MapMe is an Android library that brings the adapter pattern to Maps, simplifying the management of markers and annotations.' | ||
|
||
ext.compileSdk = 27 | ||
ext.minSdk = 15 | ||
ext.buildTools = "27.0.3" | ||
ext.kotlin_version = '1.2.31' | ||
ext.bintray_version = '1.7.3' | ||
ext.dokka_version = '0.9.15' | ||
ext.gradle_version = '3.1.0' | ||
ext.mapbox_version = '5.1.3' | ||
ext.google_play_services_version = '11.8.0' | ||
ext.android_support_version = '27.0.1' | ||
ext.android_maven_version = '3.3.0' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,116 +1,37 @@ | ||
apply plugin: 'maven-publish' | ||
apply plugin: 'com.jfrog.bintray' | ||
if (project.plugins.hasPlugin("com.android.library")) { | ||
|
||
project.afterEvaluate { | ||
if (project.plugins.hasPlugin("com.android.library")) { | ||
apply plugin: 'digital.wup.android-maven-publish' | ||
|
||
project.android.libraryVariants.all { variant -> | ||
variant.outputs.all { | ||
def newName = "${project.name}-v${project.version}.aar" | ||
outputFileName = newName | ||
} | ||
} | ||
} | ||
} | ||
|
||
project.group = project.ext.group | ||
project.version = project.ext.version | ||
|
||
bintray { | ||
user = project.hasProperty("BINTRAY_USERNAME") ? project.property('BINTRAY_USERNAME') : null | ||
key = project.hasProperty("BINTRAY_API_KEY") ? project.property('BINTRAY_API_KEY') : null | ||
pkg { | ||
repo = 'MapMe' | ||
name = getArtifactId() | ||
userOrg = 'trademe' | ||
licenses = ['Apache-2.0'] | ||
vcsUrl = project.ext.scm | ||
version { | ||
name = project.version | ||
desc = project.ext.description | ||
released = new Date() | ||
vcsTag = project.version | ||
project.afterEvaluate { | ||
task sourcesJar(type: Jar) { | ||
from android.sourceSets.main.java.srcDirs | ||
} | ||
publications = ['Bintray'] | ||
} | ||
} | ||
|
||
// Create the pom configuration: | ||
def pomConfig = { | ||
licenses { | ||
license { | ||
name "MIT License" | ||
url "http://www.opensource.org/licenses/mit-license.php" | ||
distribution "repo" | ||
publishing { | ||
publications { | ||
aar(MavenPublication) { | ||
from project.components.android | ||
artifact project.sourcesJar { | ||
// not required, includes sourcesJar with correct classifier | ||
classifier "sources" | ||
} | ||
groupId project.group | ||
artifactId project.name | ||
version project.ext.version | ||
} | ||
} | ||
} | ||
scm { | ||
url ext.scm | ||
} | ||
} | ||
|
||
//create a jar from source files | ||
task sourceJar(type: Jar) { | ||
if (project.plugins.hasPlugin("com.android.library")) { | ||
from android.sourceSets.main.java.srcDirs | ||
classifier "sources" | ||
} | ||
} | ||
|
||
publishing.publications { | ||
Bintray(MavenPublication) { | ||
groupId project.ext.group | ||
artifactId getArtifactId() | ||
version project.ext.version | ||
repositories { | ||
maven { | ||
name 'Bintray' | ||
url "https://api.bintray.com/maven/${project.org}/${project.repo}/${project.name}/;publish=1" | ||
|
||
artifact sourceJar | ||
artifact "$buildDir/outputs/aar/${project.name}-v${project.version}.aar" | ||
|
||
//generate pom nodes for dependencies | ||
//when a project references another project, it's artifact node is generated | ||
pom.withXml { | ||
def root = asNode() | ||
root.appendNode('description', project.ext.description) | ||
root.appendNode('name', project.ext.name) | ||
root.appendNode('url', project.ext.scm) | ||
root.children().last() + pomConfig | ||
|
||
def dependenciesNode = root.appendNode('dependencies') | ||
|
||
configurations.compile.allDependencies.each { dependency -> | ||
if (dependency.group != null && dependency.name != null) { | ||
|
||
if (dependency instanceof ProjectDependency) { | ||
dependency.getDependencyProject().getArtifacts().each { artifact -> | ||
addDependencyNodeToPom(dependenciesNode, dependency.group, getArtifactId(dependency.dependencyProject), dependency.version) | ||
} | ||
} else { | ||
addDependencyNodeToPom(dependenciesNode, dependency.group, dependency.name, dependency.version) | ||
} | ||
credentials { | ||
username BINTRAY_USERNAME | ||
password BINTRAY_API_KEY | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
def getArtifactId() { | ||
return getArtifactId(project) | ||
|
||
} | ||
|
||
def getArtifactId(someProject) { | ||
if (!someProject.ext.has('artifactId')) { | ||
//default artifactId is the project/module name | ||
return someProject.getName(); | ||
|
||
} | ||
return someProject.ext.artifactId; | ||
} | ||
|
||
|
||
def addDependencyNodeToPom(dependenciesNode, group, artifact, version) { | ||
def dependencyNode = dependenciesNode.appendNode('dependency') | ||
dependencyNode.appendNode("groupId", group) | ||
dependencyNode.appendNode("artifactId", artifact) | ||
dependencyNode.appendNode("version", version) | ||
} |