Skip to content

Instantly share code, notes, and snippets.

@delor
Created November 21, 2014 20:57
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save delor/f70560f14674b322dcd2 to your computer and use it in GitHub Desktop.
Save delor/f70560f14674b322dcd2 to your computer and use it in GitHub Desktop.
Gradle task for generating Maven's POM file for Android AAR
task createPom {
apply plugin: 'maven'
description "Generates pom.xml"
pom {
project {
groupId 'com.example'
artifactId 'example'
version '0.0.1-SNAPSHOT'
packaging 'aar'
}
}.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
configurations.compile.allDependencies.each { dependency ->
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', dependency.group)
dependencyNode.appendNode('artifactId', dependency.name)
dependencyNode.appendNode('version', dependency.version)
}
}.writeTo("$buildDir/pom.xml")
}
@PLNech
Copy link

PLNech commented Oct 14, 2016

Trying to run this results in the following exception:

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/user/Work/project/module/build.gradle' line: 179

* What went wrong:
A problem occurred evaluating project ':instantsearch'.
> No such property: pom for class: java.lang.String

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment