Skip to content

Commit

Permalink
Publish to Maven with proper metadata
Browse files Browse the repository at this point in the history
This allows the Maven publish to pick up information from the android
library component and include things like dependencies in the pom.xml
file.
  • Loading branch information
dpogue committed Oct 8, 2022
1 parent 38e95ee commit 877c76d
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 53 deletions.
6 changes: 6 additions & 0 deletions framework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ android {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
}

publishing {
singleVariant('release') {
withSourcesJar()
}
}
}

dependencies {
Expand Down
102 changes: 49 additions & 53 deletions framework/cordova-publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,73 +46,69 @@ if (project.hasProperty('signEnabled')) {
}
}

task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}

publishing {
publications {
mavenJava(MavenPublication) {
groupId = 'org.apache.cordova'
artifactId = 'framework'
version = getCordovaAndroidVersion()

artifact(sourcesJar)
artifact("$buildDir/outputs/aar/framework-release.aar")

pom {
name = 'Cordova'
description = 'A library to build Cordova-based projects for the Android platform.'
url = 'https://cordova.apache.org'

licenses {
license {
name = 'Apache License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
afterEvaluate {
publishing {
publications {
mavenJava(MavenPublication) {
groupId = 'org.apache.cordova'
artifactId = 'framework'
version = getCordovaAndroidVersion()

from components.release

pom {
name = 'Cordova'
description = 'A library to build Cordova-based projects for the Android platform.'
url = 'https://cordova.apache.org'

licenses {
license {
name = 'Apache License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
}

developers {
developer {
id = 'stevengill'
name = 'Steve Gill'
developers {
developer {
id = 'stevengill'
name = 'Steve Gill'
}
developer {
id = 'erisu'
name = 'Bryan Ellis'
email = 'erisu@apache.org'
}
}
developer {
id = 'erisu'
name = 'Bryan Ellis'
email = 'erisu@apache.org'
}
}

scm {
connection = 'scm:git:https://github.com/apache/cordova-android.git'
developerConnection = 'scm:git:git@github.com:apache/cordova-android.git'
url = 'https://github.com/apache/cordova-android'
scm {
connection = 'scm:git:https://github.com/apache/cordova-android.git'
developerConnection = 'scm:git:git@github.com:apache/cordova-android.git'
url = 'https://github.com/apache/cordova-android'
}
}
}
}
}

repositories {
maven {
def releasesRepoUrl = 'https://repository.apache.org/content/repositories/releases'
def snapshotsRepoUrl = 'https://repository.apache.org/content/repositories/snapshots'
repositories {
maven {
def releasesRepoUrl = 'https://repository.apache.org/content/repositories/releases'
def snapshotsRepoUrl = 'https://repository.apache.org/content/repositories/snapshots'

url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl

credentials {
if (project.hasProperty('apacheUsername') && project.hasProperty('apachePassword')) {
username apacheUsername
password apachePassword
credentials {
if (project.hasProperty('apacheUsername') && project.hasProperty('apachePassword')) {
username apacheUsername
password apachePassword
}
}
}
}
}

signing {
if (Boolean.valueOf(cdvEnableSigning)) {
sign publishing.publications.mavenJava
signing {
if (Boolean.valueOf(cdvEnableSigning)) {
sign publishing.publications.mavenJava
}
}
}
}
Expand Down

0 comments on commit 877c76d

Please sign in to comment.