Created
March 29, 2020 08:01
-
-
Save dragneelfps/d238c5cf850af08e06994e749aae6053 to your computer and use it in GitHub Desktop.
Helper for publishing artifact to maven
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
fun Project.configurePublishing(artifactId: String, android: Boolean = false) { | |
var publishingExtension: PublishingExtension? = null | |
apply<MavenPublishPlugin>() | |
apply<SigningPlugin>() | |
configure<PublishingExtension> { | |
publishingExtension = this | |
publications { | |
create<MavenPublication>("mavenRelease") { | |
this.artifactId = artifactId | |
if (android) { | |
from(components["release"]) | |
} else { | |
from(components["kotlin"]) | |
} | |
} | |
repositories { | |
maven { | |
url = uri("$buildDir/repos/releases") | |
} | |
} | |
} | |
} | |
configure<SigningExtension> { | |
sign(publishingExtension!!.publications["mavenRelease"]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment