Last active
May 4, 2022 07:11
-
-
Save ibrahimsn98/3524fab9a4cea060b1824d84a79cee8e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| apply plugin: 'maven-publish' | |
| static def isReleaseBuild() { | |
| return !Config.versionName.contains("SNAPSHOT") | |
| } | |
| def getOutputDir() { | |
| if (isReleaseBuild()) { | |
| return "${project.buildDir}/releases" | |
| } else { | |
| return "${project.buildDir}/snapshots" | |
| } | |
| } | |
| def getArtifactFilePath() { | |
| if (isReleaseBuild()) { | |
| return "$buildDir/outputs/aar/${Config.artifactId}-release.aar" | |
| } else { | |
| return "$buildDir/outputs/aar/${Config.artifactId}-debug.aar" | |
| } | |
| } | |
| def getPublicationName() { | |
| if (isReleaseBuild()) { | |
| return "release" | |
| } else { | |
| return "debug" | |
| } | |
| } | |
| publishing { | |
| publications { | |
| "${getPublicationName()}" (MavenPublication) { | |
| groupId Config.groupId // com.company.project | |
| artifactId Config.artifactId // my-component-library | |
| version Config.versionName // 1.0.0-SNAPSHOT | |
| artifact getArtifactFilePath() | |
| // To include project dependencies | |
| pom.withXml { | |
| def dependencies = asNode().appendNode('dependencies') | |
| configurations.getByName("${getPublicationName()}CompileClasspath").getResolvedConfiguration().getFirstLevelModuleDependencies().each { | |
| def dependency = dependencies.appendNode('dependency') | |
| dependency.appendNode('groupId', it.moduleGroup) | |
| dependency.appendNode('artifactId', it.moduleName) | |
| dependency.appendNode('version', it.moduleVersion) | |
| } | |
| } | |
| } | |
| } | |
| repositories { | |
| maven { | |
| url "https://gitlab.com/api/v4/projects/projectId/packages/maven" | |
| credentials(HttpHeaderCredentials) { | |
| name = "Private-Token" | |
| value = Config.gitLabAccessToken | |
| } | |
| authentication { | |
| header(HttpHeaderAuthentication) | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Execution failed for task ':generatePomFileForChatPublication'.
Adding this at the root, where is this supposed to be run?